-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·123 lines (107 loc) · 3.75 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/usr/bin/env sh
# Copyright 2024-present Contanize contributors.
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
NC='\033[0m'
# Function to check Linux distribution
check_distro() {
if [ -f /etc/os-release ]; then
. /etc/os-release
DISTRO=$ID
elif [ -f /etc/lsb-release ]; then
. /etc/lsb-release
DISTRO=$DISTRIB_ID
elif [ -f /etc/redhat-release ]; then
DISTRO=$(cat /etc/redhat-release | cut -d ' ' -f 1)
else
DISTRO="Unknown"
fi
echo -e "\n${PURPLE}Linux Distribution: $DISTRO${NC}"
}
# Function to check Go and Docker installations
check_installations() {
if ! command -v docker >/dev/null 2>&1; then
echo -e "${RED}Docker is not installed.${NC}"
echo "Please install Docker from https://docs.docker.com/get-docker/"
INSTALL_DOCKER=true
else
echo -e "${GREEN}Docker is installed.${NC}"
fi
if ! docker buildx version >/dev/null 2>&1; then
echo -e "${RED}Docker Buildx is not installed or not configured.${NC}"
echo "Please install Docker Buildx from https://docs.docker.com/buildx/working-with-buildx/"
INSTALL_BUILDX=true
else
echo -e "${GREEN}Docker Buildx is installed.${NC}"
fi
if ! pkg-config --exists webkit2gtk-4.0; then
echo -e "${RED}webkit2gtk is not installed.${NC}"
INSTALL_WEBKIT=true
else
echo -e "${GREEN}webkit2gtk is installed.${NC}"
fi
if ! command -v go >/dev/null 2>&1; then
echo -e "${RED}Go is not installed.${NC}"
echo "Please install Go from https://golang.org/dl/"
INSTALL_GO=true
else
echo -e "${GREEN}Go is installed.${NC}"
fi
if [ "$INSTALL_DOCKER" = true ] || [ "$INSTALL_BUILDX" = true ] || [ "$INSTALL_GO" = true ] || [ "$INSTALL_WEBKIT" = true ]; then
echo -e "\n${YELLOW}Please install the missing dependencies and run the script again.${NC}"
exit 1
fi
}
# Function to clone contanize repository, move files, and clean up
setup_contanize() {
echo -e "\n${CYAN}Cloning contanize repository...${NC}"
CONTANIZE_DIR="$HOME/.contanize"
git clone https://github.com/harshau007/contanize.git "$CONTANIZE_DIR" || {
echo -e "${RED}Failed to clone contanize repository.${NC}"
exit 1
}
cd "$CONTANIZE_DIR" || exit 1
echo -e "\n${BLUE}Moving contanize binary...${NC}"
sudo cp build/bin/contanize /usr/bin/ || {
echo -e "${RED}Failed to move contanize binary.${NC}"
remove_repo "$REPO_DIR"
remove_repo "$CONTANIZE_DIR"
exit 1
}
echo -e "\n${BLUE}Moving contanize.desktop...${NC}"
sudo cp LinuxBuild/contanize.desktop /usr/share/applications/ || {
echo -e "${RED}Failed to move contanize.desktop.${NC}"
remove_repo "$REPO_DIR"
remove_repo "$CONTANIZE_DIR"
exit 1
}
echo -e "\n${BLUE}Moving Essentials...${NC}"
sudo mkdir /usr/local/share/contanize
sudo cp LinuxBuild/dockerfile LinuxBuild/settings.json LinuxBuild/setup.sh /usr/local/share/contanize/ || {
echo -e "${RED}Failed to copy essentials files.${NC}"
remove_repo
exit 1
}
echo -e "\n${BLUE}Moving contanize.png...${NC}"
sudo cp LinuxBuild/contanize.png /usr/share/pixmaps/ || {
echo -e "${RED}Failed to move contanize.png.${NC}"
remove_repo "$REPO_DIR"
remove_repo "$CONTANIZE_DIR"
exit 1
}
echo -e "\n${GREEN}Setup completed for contanize!${NC}"
remove_repo "$CONTANIZE_DIR"
}
# Function to remove the cloned repository
remove_repo() {
rm -rf "$1"
}
# Function to handle script exit
trap 'remove_repo "$REPO_DIR"; remove_repo "$CONTANIZE_DIR"' EXIT
check_distro
check_installations
setup_contanize