-
Notifications
You must be signed in to change notification settings - Fork 15
/
install.sh
executable file
·181 lines (162 loc) · 6.19 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!/bin/bash
RED='\033[0;31m'
GREEN='\033[0;32m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
LICENCE_SERVER="https://cloud.uibakery.io/onpremise/license"
GET_KEY_LINK="https://cloud.uibakery.io/onpremise/get-license"
SESSION_ID=$(LC_ALL=C tr -cd "A-Za-z0-9" < /dev/urandom | head -c 42 | xargs -0)
printf "${GREEN}Welcome to UI Bakery installation script. Setup process won't take more than a couple of minutes.\n${NC}"
printf "${CYAN}Starting dependencies configuration...\n${NC}"
curl --connect-timeout 10 --max-time 20 -s -XPOST -H "Content-type: application/json" -d '{"event": "start", "session": "'"${SESSION_ID}"'"}' $LICENCE_SERVER &> /dev/null
MIN_VERSION_DOCKER="20.10.11"
MIN_VERSION_DOCKER_COMPOSE="1.29.2"
function check_version {
local Q_INSTALL_DOCKER="NO"
local IFS=""
if [[ "$1" == "DOCKER" ]]; then
IFS='.' read -ra min_version <<< "$MIN_VERSION_DOCKER"
else
IFS='.' read -ra min_version <<< "$MIN_VERSION_DOCKER_COMPOSE"
fi
IFS=' ' read -ra version_array <<< "$2"
IFS='.' read -ra subsubversion_array <<< "${version_array[2]}"
local c_version="${subsubversion_array[0]//[[:space:]]/}"
if (( $c_version < "${min_version[0]}" )); then
Q_INSTALL_DOCKER="YES"
elif (( $c_version > "${min_version[0]}" )); then
Q_INSTALL_DOCKER="NO"
else
local c_subversion="${subsubversion_array[1]//[[:space:]]/}"
if (( $c_subversion < "${min_version[1]}" )); then
Q_INSTALL_DOCKER="YES"
elif (( $c_subversion > "${min_version[1]}" )); then
Q_INSTALL_DOCKER="NO"
else
IFS=',' read -ra c_subsubversion_array <<< "${subsubversion_array[2]}"
local c_subsubversion="${c_subsubversion_array[0]//[[:space:]]/}"
if (( $c_subsubversion < "${min_version[2]}" )); then
Q_INSTALL_DOCKER="YES"
else
Q_INSTALL_DOCKER="NO"
fi
fi
fi
local Q_NEED_INSTALL_DOCKER=0
if [[ "$Q_INSTALL_DOCKER" == "YES" ]]; then
echo "The minimum required version should be ${min_version[0]}.${min_version[1]}.${min_version[2]}"
echo -e "\033[0m\033[0m\033[31m You need to manually upgrade the component to at least the minimum required version. Installation will be aborted."
echo -e "\033[m"
Q_NEED_INSTALL_DOCKER=1
fi
return $Q_NEED_INSTALL_DOCKER
}
OS_ID=""
if [ -r /etc/os-release ]; then
OS_ID="$(. /etc/os-release && echo "$ID")"
fi
OS_AUTO_INSTALL="ubuntu"
NEXT_INSTALL_OPERATION=""
echo ""
echo "Checking docker ----------------------------"
I=`which docker`
if [ -n "$I" ]; then
printf "${GREEN}Docker is already installed\n${NC}"
if [[ "$OS_ID" == "$OS_AUTO_INSTALL" ]]; then
J=`docker -v`
echo "$J"
check_version "DOCKER" "$J"
f_result=$?
if (( $f_result == 0 )); then
NEED_INSTALL_DOCKER="NO"
else
NEXT_INSTALL_OPERATION="EXIT"
fi
else
echo "Make sure the installed version of docker is ${MIN_VERSION_DOCKER} or higher. Continue? Y/n (Default - Y)"
while read docker_version_y_n; do
if [[ "$docker_version_y_n" == "Y" ]] || [[ "$docker_version_y_n" == "y" ]] || [[ "$docker_version_y_n" == "" ]]; then
NEED_INSTALL_DOCKER="NO"
break
elif [[ "$docker_version_y_n" == "N" ]] || [[ "$docker_version_y_n" == "n" ]]; then
exit
else
echo "Y - yes, I have have proper version of docker; N - no, I want to exit from install"
fi
done
fi
else
if [[ "$OS_ID" == "$OS_AUTO_INSTALL" ]]; then
NEED_INSTALL_DOCKER="YES"
else
echo "Please, install docker first."
exit
fi
fi
echo ""
echo "Checking docker-compose ----------------------------"
I=`which docker-compose`
if [ -n "$I" ]; then
printf "${GREEN}Docker-compose is already installed\n${NC}"
if [[ "$OS_ID" == "$OS_AUTO_INSTALL" ]]; then
J=`docker-compose -v`
echo "$J"
check_version "DOCKER_COMPOSE" "$J"
f_result=$?
if (( $f_result == 0 )); then
NEED_INSTALL_DOCKER_COMPOSE="NO"
else
NEXT_INSTALL_OPERATION="EXIT"
fi
else
echo "Make sure the installed version of docker-compose is ${MIN_VERSION_DOCKER_COMPOSE} or higher. Continue? Y/n (Default - Y)"
while read docker_compose_version_y_n; do
if [[ "$docker_compose_version_y_n" == "Y" ]] || [[ "$docker_compose_version_y_n" == "y" ]] || [[ "$docker_compose_version_y_n" == "" ]]; then
NEED_INSTALL_DOCKER_COMPOSE="NO"
break
elif [[ "$docker_compose_version_y_n" == "N" ]] || [[ "$docker_compose_version_y_n" == "n" ]]; then
exit
else
echo "Y - yes, I have have proper version of docker-compose; N - no, I want to exit from install"
fi
done
fi
else
if [[ "$OS_ID" == "$OS_AUTO_INSTALL" ]]; then
NEED_INSTALL_DOCKER_COMPOSE="YES"
else
echo "Please, install docker-compose first."
exit
fi
fi
if [[ "$NEXT_INSTALL_OPERATION" == "EXIT" ]]; then
exit
fi
if [[ "$NEED_INSTALL_DOCKER" == "YES" ]]; then
echo "----------------------------------------------------"
echo "Installing Docker ....."
printf "Docker installation requires sudo permissions\n"
curl -fsSL https://get.docker.com -o get-docker.sh
yes | sudo sh get-docker.sh
fi
if [[ "$NEED_INSTALL_DOCKER_COMPOSE" == "YES" ]]; then
echo "----------------------------------------------------"
echo "Installing Docker-compose ....."
sudo curl -s -L "https://github.com/docker/compose/releases/download/${MIN_VERSION_DOCKER_COMPOSE}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
fi
printf "Downloading setup files ----------------------------------\n\n"
[ -d ./ui-bakery-on-premise ] || mkdir ui-bakery-on-premise
cd ui-bakery-on-premise
if [[ "$1" == "TEST" ]]; then
cp ../setup.sh ./setup.sh
cp ../update.sh ./update.sh
else
curl -s -k -L -o setup.sh https://raw.githubusercontent.com/uibakery/self-hosted/main/setup.sh
curl -s -k -L -o update.sh https://raw.githubusercontent.com/uibakery/self-hosted/main/update.sh
fi
curl -s -k -L -o docker-compose.yml https://raw.githubusercontent.com/uibakery/self-hosted/main/docker-compose.yml
export SESSION_ID
bash ./setup.sh
echo "Starting the application... May require sudo password"
sudo docker-compose up -d