forked from simatec/piler-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
256 lines (215 loc) · 7.48 KB
/
update.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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
#!/bin/bash
# Colors
if [ -z ${BASH_SOURCE} ]; then
blue=`echo "\e[1m\e[34m"`
green=`echo "\e[1m\e[32m"`
greenBold=`echo "\e[1m\e[1;32m"`
redBold=`echo "\e[1m\e[1;31m"`
red=`echo "\e[1m\e[31m"`
purple=`echo "\e[1m\e[35m"`
bold=`echo "\e[1m"`
normal=`echo "\e[0m"`
else
blue=`echo -e "\e[1m\e[34m"`
green=`echo -e "\e[1m\e[32m"`
greenBold=`echo -e "\e[1m\e[1;32m"`
redBold=`echo -e "\e[1m\e[1;31m"`
purple=`echo -e "\e[1m\e[35m"`
bold=`echo -e "\e[1m"`
normal=`echo -en "\e[0m"`
fi
HLINE="================================================================"
HLINE_SMALL="================================="
BLA_metro=( 0.2 ' ' '= ' '== ' '=== ' ' ===' ' ==' ' =' )
BLA::play_loading_animation_loop() {
while true ; do
for frame in "${BLA_active_loading_animation[@]}" ; do
printf "\r%s" "${frame}"
sleep "${BLA_loading_animation_frame_interval}"
done
done
}
BLA::start_loading_animation() {
BLA_active_loading_animation=( "${@}" )
BLA_loading_animation_frame_interval="${BLA_active_loading_animation[0]}"
unset "BLA_active_loading_animation[0]"
tput civis # Hide the terminal cursor
BLA::play_loading_animation_loop &
BLA_loading_animation_pid="${!}"
}
BLA::stop_loading_animation() {
kill "${BLA_loading_animation_pid}" &> /dev/null
printf "\n"
tput cnorm # Restore the terminal cursor
}
#######################################################################################
echo
echo "${greenBold}${HLINE_SMALL}"
echo "Welcome to Piler-Docker Updater"
echo "${greenBold}${HLINE_SMALL}${normal}"
echo
#######################################################################################
# App Check
for bin in curl docker git; do
if [[ -z $(which ${bin}) ]]; then echo "${redBold}Cannot find ${bin}, exiting...${normal}"; exit 1; fi
done
# Docker-Compose Check
if docker compose > /dev/null 2>&1; then
if docker compose version --short | grep "^2." > /dev/null 2>&1; then
COMPOSE_VERSION=native
echo -e "${purple}Found Docker Compose Plugin (native).${normal}"
echo -e "${purple}Setting the DOCKER_COMPOSE_VERSION Variable to native${normal}"
sleep 2
echo -e "${purple}Notice: You´ll have to update this Compose Version via your Package Manager manually!${normal}"
else
echo -e "${redBold}Cannot find Docker Compose with a Version Higher than 2.X.X.${normal}"
exit 1
fi
elif docker-compose > /dev/null 2>&1; then
if ! [[ $(alias docker-compose 2> /dev/null) ]] ; then
if docker-compose version --short | grep "^2." > /dev/null 2>&1; then
COMPOSE_VERSION=standalone
echo -e "${purple}Found Docker Compose Standalone.${normal}"
echo -e "${purple}Setting the DOCKER_COMPOSE_VERSION Variable to standalone${normal}"
sleep 2
else
echo -e "${redBold}Cannot find Docker Compose with a Version Higher than 2.X.X.${normal}"
exit 1
fi
fi
else
echo -e "${redBold}Cannot find Docker Compose.${normal}"
exit 1
fi
#######################################################################################
while true; do
read -ep "Do you want to perform the update?? (y/n): " yn
case $yn in
[Yy]* ) echo "${greenBold}********* Update started... Please wait... *********${normal}"; break;;
[Nn]* ) echo -e "${redBold} The update is canceled!${normal}"; exit;;
* ) echo -e "${redBold} Please confirm with y or n.${normal}";;
esac
done
installPth=`pwd`
configPth="$installPth/config"
etcPth="/var/lib/docker/volumes/piler-docker_piler_etc/_data"
buildPth="$installPth/build"
if [ -f $installPth/docker-compose.yml ]; then
rm $installPth/docker-compose.yml
fi
# Download yml update
echo
echo "${greenBold}${HLINE}"
echo "${greenBold} Download Update files for Piler"
echo "${greenBold}${HLINE}${normal}"
echo
# Update Files
for ymlUpdate in piler-default.yml piler-ssl.yml; do
echo
echo "${purple}${HLINE}${HLINE_SMALL}"
echo "${purple}****** Download Update $ymlUpdate ******"
#curl -o $configPth/$ymlUpdate https://raw.githubusercontent.com/simatec/piler-docker/main/config/$ymlUpdate
wget https://raw.githubusercontent.com/simatec/piler-docker/main/config/$ymlUpdate -O $configPth/$ymlUpdate
echo "${purple}${HLINE}${HLINE_SMALL}${normal}"
echo
done
for fileUpdate in install-piler.sh LICENSE piler.conf.example; do
echo
echo "${purple}${HLINE}${HLINE_SMALL}"
echo "${purple}****** Download Update $fileUpdate ******"
#curl -o $installPth/$fileUpdate https://raw.githubusercontent.com/simatec/piler-docker/main/$fileUpdate
wget https://raw.githubusercontent.com/simatec/piler-docker/main/$fileUpdate -O $installPth/$fileUpdate
echo "${purple}${HLINE}${HLINE_SMALL}${normal}"
echo
done
for buildUpdate in start.sh build.sh Dockerfile build.conf; do
echo
echo "${purple}${HLINE}${HLINE_SMALL}"
echo "${purple}****** Download Update $buildUpdate ******"
#curl -o $buildPth/$buildUpdate https://raw.githubusercontent.com/simatec/piler-docker/main/build/$buildUpdate
wget https://raw.githubusercontent.com/simatec/piler-docker/main/build/$buildUpdate -O $buildPth/$buildUpdate
echo "${purple}${HLINE}${HLINE_SMALL}${normal}"
echo
done
# build config load
. $buildPth/build.conf
# set Piler Version
sed -i 's/PILER_VERSION=.*/PILER_VERSION="'$PILER_VERSION'"/g' ./piler.conf
# set Maria-DB Version
sed -i 's/MARIA_DB_VERSION=.*/MARIA_DB_VERSION="'$MARIA_DB_VERSION'"/g' ./piler.conf
# config load
. ./piler.conf
if [ ! -f $installPth/.env ]; then
ln -s ./piler.conf .env
fi
# old docker stop
cd $installPth
if [ $COMPOSE_VERSION = native ]; then
docker compose down
else
docker-compose down
fi
# Backup Config
if [ ! -d $installPth/backup ]; then
mkdir -p $installPth/backup
fi
cp -rf $etcPth/* $installPth/backup/
# delete old files
#rm -f $etcPth/piler.key $etcPth/piler.pem $etcPth/config-site.php
# Added Manticore
if [ ! -f $etcPth/MANTICORE ]; then
touch $etcPth/MANTICORE
fi
# Build Piler
#cd $buildPth
#echo "${greenBold}Start Piler-Build...${normal}" && \
#bash build.sh && \
#echo "${greenBold}Piler-Build finish${normal}"
# Copy docker-compose.yml
if [ "$USE_LETSENCRYPT" = "yes" ]; then
cp $configPth/piler-ssl.yml $installPth/docker-compose.yml
else
cp $configPth/piler-default.yml $installPth/docker-compose.yml
fi
# start Update Container
echo
echo "${greenBold}${HLINE}"
echo "${greenBold} Update Container for Piler"
echo "${greenBold}${HLINE}${normal}"
echo
if [ "$USE_LETSENCRYPT" = "yes" ]; then
if ! docker network ls | grep -o "nginx-proxy"; then
docker network create nginx-proxy
echo
echo "${blue}${HLINE}"
echo "${blue} docker network created"
echo "${blue}${HLINE}${normal}"
echo
fi
fi
if [ $COMPOSE_VERSION = native ]; then
docker compose up --force-recreate --build -d
else
docker-compose up --force-recreate --build -d
fi
echo
echo "${greenBold}${HLINE}"
echo "${greenBold} Piler Update completed successfully"
echo "${greenBold}${HLINE}${normal}"
echo
echo
echo "${greenBold}${HLINE}${HLINE_SMALL}"
if [ "$USE_LETSENCRYPT" = "yes" ]; then
echo "${greenBold}you can start in your Browser with https://${PILER_DOMAIN}!"
else
echo "${greenBold}you can start in your Browser with:"
echo "${greenBold}http://${PILER_DOMAIN} or http://local-ip"
fi
echo "${greenBold}${HLINE}${HLINE_SMALL}${normal}"
echo
echo "${blue}${HLINE}"
echo "${blue}You can remove the old unused containers on your system!"
echo "${blue}Execute the following command: docker system prune"
echo "${blue}${HLINE}${normal}"
echo
exit 0