piler-docker/update.sh

257 lines
7.5 KiB
Bash
Raw Normal View History

2022-12-18 12:15:56 +00:00
#!/bin/bash
# Colors
if [ -z ${BASH_SOURCE} ]; then
2022-12-19 13:15:39 +00:00
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"`
2022-12-18 12:15:56 +00:00
else
2022-12-19 13:15:39 +00:00
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"`
2022-12-18 12:15:56 +00:00
fi
2023-01-19 09:26:11 +00:00
HLINE="================================================================"
HLINE_SMALL="================================="
2022-12-18 12:15:56 +00:00
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
}
#######################################################################################
2023-01-19 09:26:11 +00:00
echo
echo "${greenBold}${HLINE_SMALL}"
echo "Welcome to Piler-Docker Updater"
echo "${greenBold}${HLINE_SMALL}${normal}"
echo
#######################################################################################
2023-01-18 15:46:49 +00:00
2023-01-18 15:26:51 +00:00
# App Check
for bin in curl docker git; do
2023-01-18 15:46:49 +00:00
if [[ -z $(which ${bin}) ]]; then echo "${redBold}Cannot find ${bin}, exiting...${normal}"; exit 1; fi
2023-01-18 15:26:51 +00:00
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
2023-01-18 15:46:49 +00:00
echo -e "${purple}Found Docker Compose Plugin (native).${normal}"
echo -e "${purple}Setting the DOCKER_COMPOSE_VERSION Variable to native${normal}"
2023-01-18 15:26:51 +00:00
sleep 2
echo -e "${purple}Notice: You´ll have to update this Compose Version via your Package Manager manually!${normal}"
else
2023-01-18 15:46:49 +00:00
echo -e "${redBold}Cannot find Docker Compose with a Version Higher than 2.X.X.${normal}"
2023-01-18 15:26:51 +00:00
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
2023-01-18 15:46:49 +00:00
echo -e "${purple}Found Docker Compose Standalone.${normal}"
echo -e "${purple}Setting the DOCKER_COMPOSE_VERSION Variable to standalone${normal}"
2023-01-18 15:26:51 +00:00
sleep 2
else
2023-01-18 15:46:49 +00:00
echo -e "${redBold}Cannot find Docker Compose with a Version Higher than 2.X.X.${normal}"
2023-01-18 15:26:51 +00:00
exit 1
fi
fi
else
2023-01-18 15:46:49 +00:00
echo -e "${redBold}Cannot find Docker Compose.${normal}"
2023-01-18 15:26:51 +00:00
exit 1
fi
#######################################################################################
2022-12-18 15:28:27 +00:00
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;;
2023-01-18 15:46:49 +00:00
* ) echo -e "${redBold} Please confirm with y or n.${normal}";;
2022-12-18 15:28:27 +00:00
esac
done
2023-01-19 08:44:17 +00:00
installPth=`pwd`
configPth="$installPth/config"
2022-12-19 12:43:14 +00:00
etcPth="/var/lib/docker/volumes/piler-docker_piler_etc/_data"
2023-01-22 19:02:53 +00:00
buildPth="$installPth/build"
2022-12-18 12:15:56 +00:00
if [ -f $installPth/docker-compose.yml ]; then
2023-01-19 08:44:17 +00:00
rm $installPth/docker-compose.yml
2022-12-18 12:15:56 +00:00
fi
# Download yml update
echo
echo "${greenBold}${HLINE}"
echo "${greenBold} Download Update files for Piler"
echo "${greenBold}${HLINE}${normal}"
echo
2023-01-19 08:44:17 +00:00
# Update Files
for ymlUpdate in piler-default.yml piler-ssl.yml; do
echo
echo "${purple}${HLINE}${HLINE_SMALL}"
echo "${purple}****** Download Update $ymlUpdate ******"
2023-01-26 20:48:51 +00:00
#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
2023-01-19 08:44:17 +00:00
echo "${purple}${HLINE}${HLINE_SMALL}${normal}"
echo
done
2022-12-18 12:15:56 +00:00
2023-01-19 08:44:17 +00:00
for fileUpdate in install-piler.sh LICENSE piler.conf.example; do
echo
echo "${purple}${HLINE}${HLINE_SMALL}"
echo "${purple}****** Download Update $fileUpdate ******"
2023-01-26 20:48:51 +00:00
#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
2023-01-19 08:44:17 +00:00
echo "${purple}${HLINE}${HLINE_SMALL}${normal}"
echo
done
2022-12-20 11:11:17 +00:00
2023-01-22 21:12:37 +00:00
for buildUpdate in start.sh build.sh Dockerfile build.conf; do
2023-01-22 19:02:53 +00:00
echo
echo "${purple}${HLINE}${HLINE_SMALL}"
echo "${purple}****** Download Update $buildUpdate ******"
2023-01-26 20:48:51 +00:00
#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
2023-01-22 19:02:53 +00:00
echo "${purple}${HLINE}${HLINE_SMALL}${normal}"
echo
done
2023-01-23 20:37:49 +00:00
# build config load
2023-01-23 20:48:04 +00:00
. $buildPth/build.conf
2023-01-23 20:37:49 +00:00
# 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
2022-12-18 12:15:56 +00:00
# old docker stop
cd $installPth
2023-01-18 15:26:51 +00:00
if [ $COMPOSE_VERSION = native ]; then
2023-01-19 08:44:17 +00:00
docker compose down
2023-01-18 15:26:51 +00:00
else
2023-01-19 08:44:17 +00:00
docker-compose down
2023-01-18 15:26:51 +00:00
fi
2022-12-18 12:15:56 +00:00
2023-01-22 19:02:53 +00:00
# Backup Config
if [ ! -d $installPth/backup ]; then
mkdir -p $installPth/backup
fi
2023-01-23 14:11:22 +00:00
cp -rf $etcPth/* $installPth/backup/
2023-01-22 19:02:53 +00:00
# delete old files
2023-01-23 11:51:07 +00:00
#rm -f $etcPth/piler.key $etcPth/piler.pem $etcPth/config-site.php
2023-01-22 19:02:53 +00:00
# Added Manticore
if [ ! -f $etcPth/MANTICORE ]; then
touch $etcPth/MANTICORE
fi
# Build Piler
2023-01-23 20:37:49 +00:00
#cd $buildPth
#echo "${greenBold}Start Piler-Build...${normal}" && \
#bash build.sh && \
#echo "${greenBold}Piler-Build finish${normal}"
2023-01-22 19:02:53 +00:00
# Copy docker-compose.yml
2022-12-18 12:15:56 +00:00
if [ "$USE_LETSENCRYPT" = "yes" ]; then
2023-01-19 08:44:17 +00:00
cp $configPth/piler-ssl.yml $installPth/docker-compose.yml
2022-12-18 12:15:56 +00:00
else
2023-01-19 08:44:17 +00:00
cp $configPth/piler-default.yml $installPth/docker-compose.yml
2022-12-18 12:15:56 +00:00
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
2023-01-19 08:44:17 +00:00
docker network create nginx-proxy
2022-12-18 12:15:56 +00:00
2023-01-19 08:44:17 +00:00
echo
echo "${blue}${HLINE}"
echo "${blue} docker network created"
echo "${blue}${HLINE}${normal}"
echo
2022-12-18 12:15:56 +00:00
fi
fi
2023-01-18 15:26:51 +00:00
if [ $COMPOSE_VERSION = native ]; then
2023-01-19 08:44:17 +00:00
docker compose up --force-recreate --build -d
2023-01-18 15:26:51 +00:00
else
2023-01-19 08:44:17 +00:00
docker-compose up --force-recreate --build -d
2023-01-18 15:26:51 +00:00
fi
2022-12-18 12:15:56 +00:00
echo
echo "${greenBold}${HLINE}"
echo "${greenBold} Piler Update completed successfully"
echo "${greenBold}${HLINE}${normal}"
echo
echo
2023-01-19 08:44:17 +00:00
echo "${greenBold}${HLINE}${HLINE_SMALL}"
2022-12-18 12:15:56 +00:00
if [ "$USE_LETSENCRYPT" = "yes" ]; then
2023-01-19 08:44:17 +00:00
echo "${greenBold}you can start in your Browser with https://${PILER_DOMAIN}!"
2022-12-18 12:15:56 +00:00
else
2023-01-19 08:44:17 +00:00
echo "${greenBold}you can start in your Browser with:"
echo "${greenBold}http://${PILER_DOMAIN} or http://local-ip"
2022-12-18 12:15:56 +00:00
fi
2023-01-19 08:44:17 +00:00
echo "${greenBold}${HLINE}${HLINE_SMALL}${normal}"
2022-12-18 12:15:56 +00:00
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}"
2023-01-22 20:37:54 +00:00
echo
2023-01-23 11:51:07 +00:00
exit 0