[Update] added --force mode to update skript (#3453)

master
Alexander Holzapfel 2020-04-07 13:28:51 +02:00 committed by GitHub
parent 40b203218f
commit 1b229412e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 10 deletions

View File

@ -88,18 +88,21 @@ docker_garbage() {
echo echo
echo " docker rmi ${IMGS_TO_DELETE[*]}" echo " docker rmi ${IMGS_TO_DELETE[*]}"
echo echo
if [ ! $FORCE ]; then
read -r -p "Do you want to delete old image tags right now? [y/N] " response read -r -p "Do you want to delete old image tags right now? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]; then if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
docker rmi ${IMGS_TO_DELETE[*]} docker rmi ${IMGS_TO_DELETE[*]}
else else
echo "OK, skipped." echo "OK, skipped."
fi fi
else
echo "Skipped image removal because of force mode."
fi
fi fi
echo -e "\e[32mFurther cleanup...\e[0m" echo -e "\e[32mFurther cleanup...\e[0m"
echo "If you want to cleanup further garbage collected by Docker, please make sure all containers are up and running before cleaning your system by executing \"docker system prune\"" echo "If you want to cleanup further garbage collected by Docker, please make sure all containers are up and running before cleaning your system by executing \"docker system prune\""
} }
while (($#)); do while (($#)); do
case "${1}" in case "${1}" in
--check|-c) --check|-c)
@ -133,6 +136,10 @@ while (($#)); do
prefetch_images prefetch_images
exit 0 exit 0
;; ;;
-f|--force)
echo -e "\e[32mForcing Update...\e[0m"
FORCE=y
;;
--help|-h) --help|-h)
echo './update.sh [-c|--check, --ours, --gc, --skip-start, -h|--help] echo './update.sh [-c|--check, --ours, --gc, --skip-start, -h|--help]
@ -140,6 +147,7 @@ while (($#)); do
--ours - Use merge strategy "ours" to solve conflicts in favor of non-mailcow code (local changes) --ours - Use merge strategy "ours" to solve conflicts in favor of non-mailcow code (local changes)
--gc - Run garbage collector to delete old image tags --gc - Run garbage collector to delete old image tags
--skip-start - Do not start mailcow after update --skip-start - Do not start mailcow after update
-f|--force - Force update, do not ask questions
' '
exit 1 exit 1
esac esac
@ -356,7 +364,7 @@ SHA1_2=$(sha1sum update.sh)
if [[ ${SHA1_1} != ${SHA1_2} ]]; then if [[ ${SHA1_1} != ${SHA1_2} ]]; then
echo "update.sh changed, please run this script again, exiting." echo "update.sh changed, please run this script again, exiting."
chmod +x update.sh chmod +x update.sh
exit 0 exit 2
fi fi
if [[ -f mailcow.conf ]]; then if [[ -f mailcow.conf ]]; then
@ -366,11 +374,13 @@ else
exit 1 exit 1
fi fi
if [ ! $FORCE ]; then
read -r -p "Are you sure you want to update mailcow: dockerized? All containers will be stopped. [y/N] " response read -r -p "Are you sure you want to update mailcow: dockerized? All containers will be stopped. [y/N] " response
if [[ ! "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]; then if [[ ! "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
echo "OK, exiting." echo "OK, exiting."
exit 0 exit 0
fi fi
fi
echo -e "\e[32mValidating docker-compose stack configuration...\e[0m" echo -e "\e[32mValidating docker-compose stack configuration...\e[0m"
if ! docker-compose config -q; then if ! docker-compose config -q; then