From 08d0f9448e481a2f72e5b5d397b483c1ab67233c Mon Sep 17 00:00:00 2001 From: FreddleSpl0it Date: Tue, 7 Jun 2022 13:59:59 +0200 Subject: [PATCH] [Compose] move then in if statement --- generate_config.sh | 27 +++++++------- helper-scripts/_cold-standby.sh | 53 +++++++++++++--------------- helper-scripts/backup_and_restore.sh | 28 +++++++-------- update.sh | 30 +++++++--------- 4 files changed, 62 insertions(+), 76 deletions(-) diff --git a/generate_config.sh b/generate_config.sh index 45cfaf566..66c9203ac 100755 --- a/generate_config.sh +++ b/generate_config.sh @@ -30,22 +30,19 @@ for bin in openssl curl docker git awk sha1sum; do done echo "checking docker compose version..."; -if docker --help | grep compose -then - echo '' -elif docker-compose version --short | grep -m1 "^1" > /dev/null 2>&1 -then - >&2 echo -e "\e[31mWARN: Your machine is using Docker-Compose v1!\e[0m" - >&2 echo -e "\e[31mmailcow will drop the Docker-Compose v1 Support in December 2022\e[0m" - >&2 echo -e "\e[31mPlease consider a upgrade to Docker-Compose v2.\e[0m" - >&2 echo - >&2 echo - >&2 echo -e "\e[33mContinuing...\e[0m" - sleep 3 - +if docker --help | grep compose then + echo '' +elif docker-compose version --short | grep -m1 "^1" > /dev/null 2>&1 then + >&2 echo -e "\e[31mWARN: Your machine is using Docker-Compose v1!\e[0m" + >&2 echo -e "\e[31mmailcow will drop the Docker-Compose v1 Support in December 2022\e[0m" + >&2 echo -e "\e[31mPlease consider a upgrade to Docker-Compose v2.\e[0m" + >&2 echo + >&2 echo + >&2 echo -e "\e[33mContinuing...\e[0m" + sleep 3 else - >&2 echo -e "\e[31mCannot find Docker-Compose v1 or v2 on your System. Please install Docker-Compose v2 and re-run the Script.\e[0m" - exit 1 + >&2 echo -e "\e[31mCannot find Docker-Compose v1 or v2 on your System. Please install Docker-Compose v2 and re-run the Script.\e[0m" + exit 1 fi if [ -f mailcow.conf ]; then diff --git a/helper-scripts/_cold-standby.sh b/helper-scripts/_cold-standby.sh index 0ebb7e1ff..2ec857acf 100755 --- a/helper-scripts/_cold-standby.sh +++ b/helper-scripts/_cold-standby.sh @@ -86,22 +86,19 @@ function preflight_local_checks() { echo "checking docker compose version..."; - if docker --help | grep compose - then + if docker --help | grep compose then echo '' - elif docker-compose version --short | grep -m1 "^1" > /dev/null 2>&1 - then - >&2 echo -e "\e[31mWARN: Your machine is using Docker-Compose v1!\e[0m" - >&2 echo -e "\e[31mmailcow will drop the Docker-Compose v1 Support in December 2022\e[0m" - >&2 echo -e "\e[31mPlease consider a upgrade to Docker-Compose v2.\e[0m" - >&2 echo - >&2 echo - >&2 echo -e "\e[33mContinuing...\e[0m" - sleep 3 - + elif docker-compose version --short | grep -m1 "^1" > /dev/null 2>&1 then + >&2 echo -e "\e[31mWARN: Your machine is using Docker-Compose v1!\e[0m" + >&2 echo -e "\e[31mmailcow will drop the Docker-Compose v1 Support in December 2022\e[0m" + >&2 echo -e "\e[31mPlease consider a upgrade to Docker-Compose v2.\e[0m" + >&2 echo + >&2 echo + >&2 echo -e "\e[33mContinuing...\e[0m" + sleep 3 else - >&2 echo -e "\e[31mCannot find Docker-Compose v1 or v2 on your System. Please install Docker-Compose v2 and re-run the Script.\e[0m" - exit 1 + >&2 echo -e "\e[31mCannot find Docker-Compose v1 or v2 on your System. Please install Docker-Compose v2 and re-run the Script.\e[0m" + exit 1 fi if grep --help 2>&1 | head -n 1 | grep -q -i "busybox"; then @@ -147,26 +144,24 @@ function preflight_remote_checks() { -i "${REMOTE_SSH_KEY}" \ ${REMOTE_SSH_HOST} \ -p ${REMOTE_SSH_PORT} \ - -t docker --help | grep compose - then - COMPOSE_COMMAND="docker compose" + -t docker --help | grep compose then + COMPOSE_COMMAND="docker compose" elif ssh -q -o StrictHostKeyChecking=no \ -i "${REMOTE_SSH_KEY}" \ ${REMOTE_SSH_HOST} \ -p ${REMOTE_SSH_PORT} \ - 'docker-compose version --short' | grep -m1 "^1" > /dev/null 2>&1 - then - >&2 echo -e "\e[31mWARN: The remote is using Docker-Compose v1!\e[0m" - >&2 echo -e "\e[31mmailcow will drop the Docker-Compose v1 Support in December 2022\e[0m" - >&2 echo -e "\e[31mPlease consider a upgrade to Docker-Compose v2 on remote.\e[0m" - >&2 echo - >&2 echo - >&2 echo -e "\e[33mContinuing...\e[0m" - sleep 3 - COMPOSE_COMMAND="docker-compose" + 'docker-compose version --short' | grep -m1 "^1" > /dev/null 2>&1 then + >&2 echo -e "\e[31mWARN: The remote is using Docker-Compose v1!\e[0m" + >&2 echo -e "\e[31mmailcow will drop the Docker-Compose v1 Support in December 2022\e[0m" + >&2 echo -e "\e[31mPlease consider a upgrade to Docker-Compose v2 on remote.\e[0m" + >&2 echo + >&2 echo + >&2 echo -e "\e[33mContinuing...\e[0m" + sleep 3 + COMPOSE_COMMAND="docker-compose" else - >&2 echo -e "\e[31mCannot find Docker-Compose v1 or v2 on the Remote Machine! Please install Docker-Compose v2 on that and re-run the script.\e[0m" - exit 1 + >&2 echo -e "\e[31mCannot find Docker-Compose v1 or v2 on the Remote Machine! Please install Docker-Compose v2 on that and re-run the script.\e[0m" + exit 1 fi } diff --git a/helper-scripts/backup_and_restore.sh b/helper-scripts/backup_and_restore.sh index 6d5735131..f0cd5c18c 100755 --- a/helper-scripts/backup_and_restore.sh +++ b/helper-scripts/backup_and_restore.sh @@ -77,22 +77,20 @@ else fi echo "checking docker compose version..."; -if docker --help | grep compose -then - COMPOSE_COMMAND="docker compose" -elif docker-compose version --short | grep -m1 "^1" > /dev/null 2>&1 -then - >&2 echo -e "\e[31mWARN: Your machine is using Docker-Compose v1!\e[0m" - >&2 echo -e "\e[31mmailcow will drop the Docker-Compose v1 Support in December 2022\e[0m" - >&2 echo -e "\e[31mPlease consider a upgrade to Docker-Compose v2.\e[0m" - >&2 echo - >&2 echo - >&2 echo -e "\e[33mContinuing...\e[0m" - sleep 3 - COMPOSE_COMMAND="docker-compose" +if docker --help | grep compose then + COMPOSE_COMMAND="docker compose" +elif docker-compose version --short | grep -m1 "^1" > /dev/null 2>&1 then + >&2 echo -e "\e[31mWARN: Your machine is using Docker-Compose v1!\e[0m" + >&2 echo -e "\e[31mmailcow will drop the Docker-Compose v1 Support in December 2022\e[0m" + >&2 echo -e "\e[31mPlease consider a upgrade to Docker-Compose v2.\e[0m" + >&2 echo + >&2 echo + >&2 echo -e "\e[33mContinuing...\e[0m" + sleep 3 + COMPOSE_COMMAND="docker-compose" else - >&2 echo -e "\e[31mCannot find Docker-Compose v1 or v2 on your System. Please install Docker-Compose v2 and re-run the Script.\e[0m" - exit 1 + >&2 echo -e "\e[31mCannot find Docker-Compose v1 or v2 on your System. Please install Docker-Compose v2 and re-run the Script.\e[0m" + exit 1 fi if grep --help 2>&1 | head -n 1 | grep -q -i "busybox"; then diff --git a/update.sh b/update.sh index 1680da507..d7c65b773 100755 --- a/update.sh +++ b/update.sh @@ -46,24 +46,20 @@ done echo "checking docker compose version..."; -if docker --help | grep compose -then - COMPOSE_COMMAND="docker compose" - -elif docker-compose version --short | grep -m1 "^1" > /dev/null 2>&1 -then - >&2 echo -e "\e[31mWARN: Your machine is using Docker-Compose v1!\e[0m" - >&2 echo -e "\e[31mmailcow will drop the Docker-Compose v1 Support in December 2022\e[0m" - >&2 echo -e "\e[31mPlease consider a upgrade to Docker-Compose v2.\e[0m" - >&2 echo - >&2 echo - >&2 echo -e "\e[33mContinuing...\e[0m" - sleep 3 - COMPOSE_COMMAND="docker-compose" - +if docker --help | grep compose then + COMPOSE_COMMAND="docker compose" +elif docker-compose version --short | grep -m1 "^1" > /dev/null 2>&1 then + >&2 echo -e "\e[31mWARN: Your machine is using Docker-Compose v1!\e[0m" + >&2 echo -e "\e[31mmailcow will drop the Docker-Compose v1 Support in December 2022\e[0m" + >&2 echo -e "\e[31mPlease consider a upgrade to Docker-Compose v2.\e[0m" + >&2 echo + >&2 echo + >&2 echo -e "\e[33mContinuing...\e[0m" + sleep 3 + COMPOSE_COMMAND="docker-compose" else - >&2 echo -e "\e[31mCannot find Docker-Compose v1 or v2 on your System. Please install Docker-Compose v2 and re-run the Script.\e[0m" - exit 1 + >&2 echo -e "\e[31mCannot find Docker-Compose v1 or v2 on your System. Please install Docker-Compose v2 and re-run the Script.\e[0m" + exit 1 fi export LC_ALL=C DATE=$(date +%Y-%m-%d_%H_%M_%S)