From 1b229412e3bf117e63daf63b078d59177431ece9 Mon Sep 17 00:00:00 2001 From: Alexander Holzapfel Date: Tue, 7 Apr 2020 13:28:51 +0200 Subject: [PATCH] [Update] added --force mode to update skript (#3453) --- update.sh | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/update.sh b/update.sh index 481e8178..48af481d 100755 --- a/update.sh +++ b/update.sh @@ -88,18 +88,21 @@ docker_garbage() { echo echo " docker rmi ${IMGS_TO_DELETE[*]}" echo - read -r -p "Do you want to delete old image tags right now? [y/N] " response - if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]; then - docker rmi ${IMGS_TO_DELETE[*]} + if [ ! $FORCE ]; then + read -r -p "Do you want to delete old image tags right now? [y/N] " response + if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]; then + docker rmi ${IMGS_TO_DELETE[*]} + else + echo "OK, skipped." + fi else - echo "OK, skipped." + echo "Skipped image removal because of force mode." fi fi 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\"" } - while (($#)); do case "${1}" in --check|-c) @@ -133,6 +136,10 @@ while (($#)); do prefetch_images exit 0 ;; + -f|--force) + echo -e "\e[32mForcing Update...\e[0m" + FORCE=y + ;; --help|-h) 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) --gc - Run garbage collector to delete old image tags --skip-start - Do not start mailcow after update + -f|--force - Force update, do not ask questions ' exit 1 esac @@ -356,7 +364,7 @@ SHA1_2=$(sha1sum update.sh) if [[ ${SHA1_1} != ${SHA1_2} ]]; then echo "update.sh changed, please run this script again, exiting." chmod +x update.sh - exit 0 + exit 2 fi if [[ -f mailcow.conf ]]; then @@ -366,10 +374,12 @@ else exit 1 fi -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 - echo "OK, exiting." - exit 0 +if [ ! $FORCE ]; then + 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 + echo "OK, exiting." + exit 0 + fi fi echo -e "\e[32mValidating docker-compose stack configuration...\e[0m"