From eaf15d25b659c8d235c72b6050689883096375c8 Mon Sep 17 00:00:00 2001 From: andryyy Date: Tue, 20 Jun 2017 23:05:43 +0200 Subject: [PATCH] Don't need to backup images with tags --- update.sh | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/update.sh b/update.sh index e74ca162..bcda3a3b 100755 --- a/update.sh +++ b/update.sh @@ -9,6 +9,10 @@ else echo -e "\e[32mOK\e[0m" fi +if [[ -z $(which curl) ]]; then echo "Cannot find curl, exiting."; exit 1; fi +if [[ -z $(which docker-compose) ]]; then echo "Cannot find docker-compose, exiting."; exit 1; fi +if [[ -z $(which git) ]]; then echo "Cannot find git, exiting."; exit 1; fi + set -o pipefail export LC_ALL=C DATE=$(date +%Y-%m-%d_%H_%M_%S) @@ -21,16 +25,16 @@ else exit 1 fi +read -r -p "Are you sure? [y/N] " response +if [[ ! "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]; then + echo "OK, exiting." + exit 0 +fi + +echo -e "Stopping mailcow... " # Stopping mailcow docker-compose down -for image in "phpfpm" "dovecot" "postfix" "sogo" "unbound" "rspamd" "clamd" "fail2ban"; do -if [[ ! -z $(docker images mailcow/${image} -q) ]]; then - echo -e "\e[32mSaving mailcow/${image} to mailcow/${image}:${DATE}...\e[90m" - docker tag mailcow/${image} mailcow/${image}:${DATE} -fi -done - # Silently fixing remote url from andryyy to mailcow git remote set-url origin https://github.com/mailcow/mailcow-dockerized echo -e "\e[32mCommitting current status...\e[90m" @@ -38,7 +42,7 @@ git add -u git commit -am "Before update on ${DATE}" > /dev/null echo -e "\e[32mFetching updated code from remote...\e[90m" git fetch origin ${BRANCH} -echo -e "\e[32mMerging local with remote code...\e[90m" +echo -e "\e[32mMerging local with remote code (recursive, options: \"theirs\", \"patience\"...\e[90m" git merge -Xtheirs -Xpatience -m "After update on ${DATE}" if [[ $? == 1 ]]; then @@ -62,4 +66,7 @@ echo [[ ! -d data/assets/ssl ]] && mkdir -p data/assets/ssl cp -n data/assets/ssl-example/*.pem data/assets/ssl/ +curl -L https://github.com/docker/compose/releases/download/$(curl -Ls https://www.servercow.de/docker-compose/latest.php)/docker-compose-$(uname -s)-$(uname -m) > $(which docker-compose) +chmod +x $(which docker-compose) + docker-compose up -d