From 7166696aa2682617836c254e9243a3120a9243d0 Mon Sep 17 00:00:00 2001 From: DerLinkman Date: Thu, 16 Jun 2022 12:28:04 +0200 Subject: [PATCH 01/13] Readded Compose Standalone Download --- update.sh | 103 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 65 insertions(+), 38 deletions(-) diff --git a/update.sh b/update.sh index 0b9e12d26..26a09785f 100755 --- a/update.sh +++ b/update.sh @@ -44,27 +44,6 @@ for bin in curl docker git awk sha1sum; do if [[ -z $(which ${bin}) ]]; then echo "Cannot find ${bin}, exiting..."; exit 1; fi done - -echo "checking docker compose version..."; -if docker compose >/dev/null 2>&1; then - echo -e "\e[32mFound Compose v2!\e[0m" - COMPOSE_COMMAND="docker compose" -elif docker-compose version --short | grep -m1 "^2" > /dev/null 2>&1; then - echo -e "\e[32mFound Compose v2!\e[0m" - COMPOSE_COMMAND="docker-compose" -elif docker-compose version --short | grep -m1 "^1" > /dev/null 2>&1; then - echo -e "\e[33mWARN: Your machine is using Docker-Compose v1!\e[0m" - echo -e "\e[33mmailcow will drop the Docker-Compose v1 Support in December 2022\e[0m" - echo -e "\e[33mPlease consider a upgrade to Docker-Compose v2.\e[0m" - echo - echo - echo -e "\e[33mContinuing...\e[0m" - sleep 3 - COMPOSE_COMMAND="docker-compose" -else - 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) BRANCH=$(cd ${SCRIPT_DIR}; git rev-parse --abbrev-ref HEAD) @@ -218,6 +197,50 @@ migrate_docker_nat() { fi } +update_compose(){ +if [[ ${NO_UPDATE_COMPOSE} == "y" ]]; then + echo -e "\e[33mNot fetching latest docker-compose, please check for updates manually!\e[0m" + return 0 +elif [[ -e /etc/alpine-release ]]; then + echo -e "\e[33mNot fetching latest docker-compose, because you are using Alpine Linux without glibc support. Please update docker-compose via apk!\e[0m" + return 0 +else + echo -e "\e[32mFetching new docker-compose version...\e[0m" + echo -e "\e[32mTrying to determine GLIBC version...\e[0m" + if ldd --version > /dev/null; then + GLIBC_V=$(ldd --version | grep -E '(GLIBC|GNU libc)' | rev | cut -d ' ' -f1 | rev | cut -d '.' -f2) + if [ ! -z "${GLIBC_V}" ] && [ ${GLIBC_V} -gt 27 ]; then + DC_DL_SUFFIX= + else + DC_DL_SUFFIX=legacy + fi + else + DC_DL_SUFFIX=legacy + fi + sleep 1 + if [[ ! -z $(which pip) && $(pip list --local 2>&1 | grep -v DEPRECATION | grep -c docker-compose) == 1 ]]; then + true + #prevent breaking a working docker-compose installed with pip + elif [[ $(curl -sL -w "%{http_code}" https://www.servercow.de/docker-compose/latest.php?vers=${DC_DL_SUFFIX} -o /dev/null) == "200" ]]; then + LATEST_COMPOSE=$(curl -#L https://www.servercow.de/docker-compose/latest.php) + COMPOSE_VERSION=$(docker-compose version --short) + if [[ "$LATEST_COMPOSE" != "$COMPOSE_VERSION" ]]; then + COMPOSE_PATH=$(which docker-compose) + if [[ -w ${COMPOSE_PATH} ]]; then + curl -#L https://github.com/docker/compose/releases/download/v${LATEST_COMPOSE}/docker-compose-$(uname -s)-$(uname -m) > $COMPOSE_PATH + chmod +x $COMPOSE_PATH + else + echo -e "\e[33mWARNING: $COMPOSE_PATH is not writable, but new version $LATEST_COMPOSE is available (installed: $COMPOSE_VERSION)\e[0m" + return 1 + fi + fi + else + echo -e "\e[33mCannot determine latest docker-compose version, skipping...\e[0m" + return 1 + fi +fi +} + while (($#)); do case "${1}" in --check|-c) @@ -256,6 +279,9 @@ while (($#)); do echo -e "\e[32mRunning in forced mode...\e[0m" FORCE=y ;; + --no-update-compose) + NO_UPDATE_COMPOSE=y + ;; --skip-ping-check) SKIP_PING_CHECK=y ;; @@ -265,6 +291,7 @@ while (($#)); do -c|--check - Check for updates and exit (exit codes => 0: update available, 3: no updates) --ours - Use merge strategy option "ours" to solve conflicts in favor of non-mailcow code (local changes over remote changes), not recommended! --gc - Run garbage collector to delete old image tags + --no-update-compose - Do not update docker-compose --prefetch - Only prefetch new images and exit (useful to prepare updates) --skip-start - Do not start mailcow after update --skip-ping-check - Skip ICMP Check to public DNS resolvers (Use it only if you´ve blocked any ICMP Connections to your mailcow machine). @@ -281,7 +308,7 @@ source mailcow.conf DOTS=${MAILCOW_HOSTNAME//[^.]}; if [ ${#DOTS} -lt 2 ]; then echo "MAILCOW_HOSTNAME (${MAILCOW_HOSTNAME}) is not a FQDN!" - echo "Please change it to a FQDN and run ${COMPOSE_COMMAND} down followed by ${COMPOSE_COMMAND} up -d" + echo "Please change it to a FQDN and run docker-compose down followed by docker-compose up -d" exit 1 fi @@ -571,6 +598,7 @@ echo -e "\e[32mChecking for newer update script...\e[0m" SHA1_1=$(sha1sum update.sh) git fetch origin #${BRANCH} git checkout origin/${BRANCH} update.sh +git checkout origin/${BRANCH} docker-compose.yml SHA1_2=$(sha1sum update.sh) if [[ ${SHA1_1} != ${SHA1_2} ]]; then echo "update.sh changed, please run this script again, exiting." @@ -594,14 +622,16 @@ if [ ! $FORCE ]; then migrate_docker_nat fi +update_compose + echo -e "\e[32mValidating docker-compose stack configuration...\e[0m" -if ! ${COMPOSE_COMMAND} config -q; then +if ! docker-compose config -q; then echo -e "\e[31m\nOh no, something went wrong. Please check the error message above.\e[0m" exit 1 fi echo -e "\e[32mChecking for conflicting bridges...\e[0m" -MAILCOW_BRIDGE=$(${COMPOSE_COMMAND} config | grep -i com.docker.network.bridge.name | cut -d':' -f2) +MAILCOW_BRIDGE=$(docker-compose config | grep -i com.docker.network.bridge.name | cut -d':' -f2) while read NAT_ID; do iptables -t nat -D POSTROUTING $NAT_ID done < <(iptables -L -vn -t nat --line-numbers | grep $IPV4_NETWORK | grep -E 'MASQUERADE.*all' | grep -v ${MAILCOW_BRIDGE} | cut -d' ' -f1) @@ -621,8 +651,8 @@ prefetch_images echo -e "\e[32mStopping mailcow...\e[0m" sleep 2 -MAILCOW_CONTAINERS=($(${COMPOSE_COMMAND} ps -q)) -${COMPOSE_COMMAND} down +MAILCOW_CONTAINERS=($(docker-compose ps -q)) +docker-compose down echo -e "\e[32mChecking for remaining containers...\e[0m" sleep 2 for container in "${MAILCOW_CONTAINERS[@]}"; do @@ -659,16 +689,13 @@ elif [[ ${MERGE_RETURN} == 1 ]]; then elif [[ ${MERGE_RETURN} != 0 ]]; then echo -e "\e[31m\nOh no, something went wrong. Please check the error message above.\e[0m" echo - echo "Run ${COMPOSE_COMMAND} up -d to restart your stack without updates or try again after fixing the mentioned errors." + echo "Run docker-compose up -d to restart your stack without updates or try again after fixing the mentioned errors." exit 1 fi -echo -e "\e[33mNot fetching latest docker-compose, please check for updates manually!\e[0m" -sleep 3 - echo -e "\e[32mFetching new images, if any...\e[0m" sleep 2 -${COMPOSE_COMMAND} pull +docker-compose pull # Fix missing SSL, does not overwrite existing files [[ ! -d data/assets/ssl ]] && mkdir -p data/assets/ssl @@ -723,11 +750,11 @@ else fi if [[ ${SKIP_START} == "y" ]]; then - echo -e "\e[33mNot starting mailcow, please run \"${COMPOSE_COMMAND} up -d --remove-orphans\" to start mailcow.\e[0m" + echo -e "\e[33mNot starting mailcow, please run \"docker-compose up -d --remove-orphans\" to start mailcow.\e[0m" else echo -e "\e[32mStarting mailcow...\e[0m" sleep 2 - ${COMPOSE_COMMAND} up -d --remove-orphans + docker-compose up -d --remove-orphans fi echo -e "\e[32mCollecting garbage...\e[0m" @@ -738,8 +765,8 @@ if [ -f "${SCRIPT_DIR}/post_update_hook.sh" ]; then bash "${SCRIPT_DIR}/post_update_hook.sh" fi -#echo "In case you encounter any problem, hard-reset to a state before updating mailcow:" -#echo -#git reflog --color=always | grep "Before update on " -#echo -#echo "Use \"git reset --hard hash-on-the-left\" and run ${COMPOSE_COMMAND} up -d afterwards." \ No newline at end of file +# echo "In case you encounter any problem, hard-reset to a state before updating mailcow:" +# echo +# git reflog --color=always | grep "Before update on " +# echo +# echo "Use \"git reset --hard hash-on-the-left\" and run docker-compose up -d afterwards." \ No newline at end of file From a139eb9bce925e66a99639efd4b1027e020ac26a Mon Sep 17 00:00:00 2001 From: DerLinkman Date: Thu, 16 Jun 2022 12:38:06 +0200 Subject: [PATCH 02/13] Readded Dual Stack availability of WebUI (default) --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index e3b08637c..a563df918 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -377,8 +377,8 @@ services: - ./data/conf/rspamd/meta_exporter:/meta_exporter:ro,z - sogo-web-vol-1:/usr/lib/GNUstep/SOGo/ ports: - - "${HTTPS_BIND:-0.0.0.0}:${HTTPS_PORT:-443}:${HTTPS_PORT:-443}" - - "${HTTP_BIND:-0.0.0.0}:${HTTP_PORT:-80}:${HTTP_PORT:-80}" + - "${HTTPS_BIND:-}:${HTTPS_PORT:-443}:${HTTPS_PORT:-443}" + - "${HTTP_BIND:-}:${HTTP_PORT:-80}:${HTTP_PORT:-80}" restart: always networks: mailcow-network: From 36e4ee7738570f7598f227a864bf852e58ac789b Mon Sep 17 00:00:00 2001 From: DerLinkman Date: Thu, 16 Jun 2022 12:41:49 +0200 Subject: [PATCH 03/13] Before update on 2022-06-16_12_41_05 --- docker-compose.yml | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index a563df918..753901aa7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -580,36 +580,6 @@ services: aliases: - ofelia - ipv6nat-mailcow: - depends_on: - - unbound-mailcow - - mysql-mailcow - - redis-mailcow - - clamd-mailcow - - rspamd-mailcow - - php-fpm-mailcow - - sogo-mailcow - - dovecot-mailcow - - postfix-mailcow - - memcached-mailcow - - nginx-mailcow - - acme-mailcow - - netfilter-mailcow - - watchdog-mailcow - - dockerapi-mailcow - - solr-mailcow - environment: - - TZ=${TZ} - image: robbertkl/ipv6nat - security_opt: - - label=disable - restart: always - privileged: true - network_mode: "host" - volumes: - - /var/run/docker.sock:/var/run/docker.sock:ro - - /lib/modules:/lib/modules:ro - networks: mailcow-network: driver: bridge From 872fa072131873a8482bbedf049caf186f3a0ea1 Mon Sep 17 00:00:00 2001 From: DerLinkman Date: Thu, 16 Jun 2022 12:49:17 +0200 Subject: [PATCH 04/13] Restore docker-compose check in scripts --- generate_config.sh | 21 +--------- helper-scripts/_cold-standby.sh | 57 +--------------------------- helper-scripts/backup_and_restore.sh | 26 +++---------- 3 files changed, 9 insertions(+), 95 deletions(-) diff --git a/generate_config.sh b/generate_config.sh index 800f0b533..de2851787 100755 --- a/generate_config.sh +++ b/generate_config.sh @@ -25,29 +25,10 @@ if cp --help 2>&1 | grep -q -i "busybox"; then exit 1 fi -for bin in openssl curl docker git awk sha1sum; do +for bin in openssl curl docker docker-compose git awk sha1sum; do if [[ -z $(which ${bin}) ]]; then echo "Cannot find ${bin}, exiting..."; exit 1; fi done -echo "checking docker compose version..."; -if docker compose >/dev/null 2>&1; then - echo -e "\e[32mFound Compose v2!\e[0m" -elif docker-compose version --short | grep -m1 "^2" > /dev/null 2>&1; then - echo -e "\e[32mFound Compose v2!\e[0m" - COMPOSE_COMMAND="docker-compose" -elif docker-compose version --short | grep -m1 "^1" > /dev/null 2>&1; then - echo -e "\e[33mWARN: Your machine is using Docker-Compose v1!\e[0m" - echo -e "\e[33mmailcow will drop the Docker-Compose v1 Support in December 2022\e[0m" - echo -e "\e[33mPlease consider a upgrade to Docker-Compose v2.\e[0m" - echo - echo - echo -e "\e[33mContinuing...\e[0m" - sleep 3 -else - 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 read -r -p "A config file exists and will be overwritten, are you sure you want to continue? [y/N] " response case $response in diff --git a/helper-scripts/_cold-standby.sh b/helper-scripts/_cold-standby.sh index 142009540..b71d85cd5 100755 --- a/helper-scripts/_cold-standby.sh +++ b/helper-scripts/_cold-standby.sh @@ -77,33 +77,13 @@ function preflight_local_checks() { exit 1 fi - for bin in rsync docker grep cut; do + for bin in rsync docker docker-compose grep cut; do if [[ -z $(which ${bin}) ]]; then >&2 echo -e "\e[31mCannot find ${bin} in local PATH, exiting...\e[0m" exit 1 fi done - - echo "checking docker compose version..."; - if docker compose >/dev/null 2>&1; then - echo -e "\e[32mFound Compose v2 on local machine!\e[0m" - elif docker-compose version --short | grep -m1 "^2" > /dev/null 2>&1; then - echo -e "\e[32mFound Compose v2!\e[0m" - COMPOSE_COMMAND="docker-compose" - elif docker-compose version --short | grep -m1 "^1" > /dev/null 2>&1; then - echo -e "\e[33mWARN: Your machine is using Docker-Compose v1!\e[0m" - echo -e "\e[33mmailcow will drop the Docker-Compose v1 Support in December 2022\e[0m" - echo -e "\e[33mPlease consider a upgrade to Docker-Compose v2.\e[0m" - echo - echo - echo -e "\e[33mContinuing...\e[0m" - sleep 3 - else - 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 echo -e "\e[31mBusyBox grep detected on local system, please install GNU grep\e[0m" exit 1 @@ -131,7 +111,7 @@ function preflight_remote_checks() { exit 1 fi - for bin in rsync docker; do + for bin in rsync docker docker-compose; do if ! ssh -o StrictHostKeyChecking=no \ -i "${REMOTE_SSH_KEY}" \ ${REMOTE_SSH_HOST} \ @@ -141,39 +121,6 @@ function preflight_remote_checks() { exit 1 fi done - - echo "checking docker compose version on remote..."; - if ssh -q -o StrictHostKeyChecking=no \ - -i "${REMOTE_SSH_KEY}" \ - ${REMOTE_SSH_HOST} \ - -p ${REMOTE_SSH_PORT} \ - -t 'docker compose' >/dev/null 2>&1; then - echo -e "\e[32mFound Compose v2 on remote!\e[0m" - COMPOSE_COMMAND="docker compose" - elif ssh -q -o StrictHostKeyChecking=no \ - -i "${REMOTE_SSH_KEY}" \ - ${REMOTE_SSH_HOST} \ - -p ${REMOTE_SSH_PORT} \ - -t 'docker-compose version --short' | grep -m1 "^2" > /dev/null 2>&1; then - echo -e "\e[32mFound Compose v2!\e[0m" - COMPOSE_COMMAND="docker-compose" - elif ssh -q -o StrictHostKeyChecking=no \ - -i "${REMOTE_SSH_KEY}" \ - ${REMOTE_SSH_HOST} \ - -p ${REMOTE_SSH_PORT} \ - -t 'docker-compose version --short' | grep -m1 "^1" > /dev/null 2>&1; then - echo -e "\e[33mWARN: The remote is using Docker-Compose v1!\e[0m" - echo -e "\e[33mmailcow will drop the Docker-Compose v1 Support in December 2022\e[0m" - echo -e "\e[33mPlease consider a upgrade to Docker-Compose v2 on remote.\e[0m" - echo - echo - echo -e "\e[33mContinuing...\e[0m" - sleep 3 - COMPOSE_COMMAND="docker-compose" - else - 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 } preflight_local_checks diff --git a/helper-scripts/backup_and_restore.sh b/helper-scripts/backup_and_restore.sh index 8136def33..b45fcb97d 100755 --- a/helper-scripts/backup_and_restore.sh +++ b/helper-scripts/backup_and_restore.sh @@ -76,26 +76,12 @@ else CMPS_PRJ=$(echo ${COMPOSE_PROJECT_NAME} | tr -cd "[0-9A-Za-z-_]") fi -echo "checking docker compose version..."; -if docker compose >/dev/null 2>&1; then - echo -e "\e[32mFound Compose v2!\e[0m" - COMPOSE_COMMAND="docker compose" -elif docker-compose version --short | grep -m1 "^2" > /dev/null 2>&1; then - echo -e "\e[32mFound Compose v2!\e[0m" - COMPOSE_COMMAND="docker-compose" -elif docker-compose version --short | grep -m1 "^1" > /dev/null 2>&1; then - echo -e "\e[33mWARN: Your machine is using Docker-Compose v1!\e[0m" - echo -e "\e[33mmailcow will drop the Docker-Compose v1 Support in December 2022\e[0m" - echo -e "\e[33mPlease consider a upgrade to Docker-Compose v2.\e[0m" - echo - echo - echo -e "\e[33mContinuing...\e[0m" - sleep 3 - COMPOSE_COMMAND="docker-compose" -else - 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 +for bin in docker docker-compose; do + if [[ -z $(which ${bin}) ]]; then + >&2 echo -e "\e[31mCannot find ${bin} in local PATH, exiting...\e[0m" + exit 1 + fi +done if grep --help 2>&1 | head -n 1 | grep -q -i "busybox"; then >&2 echo -e "\e[31mBusyBox grep detected on local system, please install GNU grep\e[0m" From 89cea31475720a19c366fc31e620ff11525ec47b Mon Sep 17 00:00:00 2001 From: DerLinkman Date: Thu, 16 Jun 2022 12:51:51 +0200 Subject: [PATCH 05/13] Revert "Before update on 2022-06-16_12_41_05" This reverts commit 36e4ee7738570f7598f227a864bf852e58ac789b. --- docker-compose.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 753901aa7..a563df918 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -580,6 +580,36 @@ services: aliases: - ofelia + ipv6nat-mailcow: + depends_on: + - unbound-mailcow + - mysql-mailcow + - redis-mailcow + - clamd-mailcow + - rspamd-mailcow + - php-fpm-mailcow + - sogo-mailcow + - dovecot-mailcow + - postfix-mailcow + - memcached-mailcow + - nginx-mailcow + - acme-mailcow + - netfilter-mailcow + - watchdog-mailcow + - dockerapi-mailcow + - solr-mailcow + environment: + - TZ=${TZ} + image: robbertkl/ipv6nat + security_opt: + - label=disable + restart: always + privileged: true + network_mode: "host" + volumes: + - /var/run/docker.sock:/var/run/docker.sock:ro + - /lib/modules:/lib/modules:ro + networks: mailcow-network: driver: bridge From 6612b892b77c8a255580c3554eaca671dc169604 Mon Sep 17 00:00:00 2001 From: DerLinkman Date: Thu, 16 Jun 2022 12:56:54 +0200 Subject: [PATCH 06/13] Removed extra checkout line --- update.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/update.sh b/update.sh index 26a09785f..c46751a54 100755 --- a/update.sh +++ b/update.sh @@ -597,8 +597,7 @@ fi echo -e "\e[32mChecking for newer update script...\e[0m" SHA1_1=$(sha1sum update.sh) git fetch origin #${BRANCH} -git checkout origin/${BRANCH} update.sh -git checkout origin/${BRANCH} docker-compose.yml +git checkout origin/${BRANCH} update.sh docker-compose.yml SHA1_2=$(sha1sum update.sh) if [[ ${SHA1_1} != ${SHA1_2} ]]; then echo "update.sh changed, please run this script again, exiting." From 499273dbb757a6420f8d352c8f1ac0a8323f454b Mon Sep 17 00:00:00 2001 From: DerLinkman Date: Thu, 16 Jun 2022 13:50:44 +0200 Subject: [PATCH 07/13] Readded docker-compose check --- update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update.sh b/update.sh index c46751a54..3de7e5617 100755 --- a/update.sh +++ b/update.sh @@ -40,7 +40,7 @@ PATH=$PATH:/opt/bin umask 0022 -for bin in curl docker git awk sha1sum; do +for bin in curl docker docker-compose git awk sha1sum; do if [[ -z $(which ${bin}) ]]; then echo "Cannot find ${bin}, exiting..."; exit 1; fi done From dd6b8c44a4e71b0d59e2d90573a2b8c667cbb403 Mon Sep 17 00:00:00 2001 From: DerLinkman Date: Thu, 16 Jun 2022 14:13:08 +0200 Subject: [PATCH 08/13] Added automatic docker-compose standalone installation --- update.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/update.sh b/update.sh index 3de7e5617..dc47c3dee 100755 --- a/update.sh +++ b/update.sh @@ -40,8 +40,20 @@ PATH=$PATH:/opt/bin umask 0022 -for bin in curl docker docker-compose git awk sha1sum; do - if [[ -z $(which ${bin}) ]]; then echo "Cannot find ${bin}, exiting..."; exit 1; fi +for bin in curl docker git awk sha1sum; do + if [[ -z $(which ${bin}) ]]; then + echo "Cannot find ${bin}, exiting..." + exit 1; + elif [[ -z $(which docker-compose) ]]; then + echo "Cannot find docker-compose Standalone. Installing..." + sleep 3 + if [[ -e /etc/alpine-release ]]; then + echo -e "\e[33mNot installing latest docker-compose, because you are using Alpine Linux without glibc support. Install docker-compose via apk!\e[0m" + exit 1 + fi + curl -#L https://github.com/docker/compose/releases/download/v$(curl -Ls https://www.servercow.de/docker-compose/latest.php)/docker-compose-$(uname -s)-$(uname -m) > /usr/local/bin/docker-compose + chmod +x /usr/local/bin/docker-compose + fi done export LC_ALL=C From cd7715fa0e2779fecbf82a985c25e8e74603be25 Mon Sep 17 00:00:00 2001 From: FreddleSpl0it Date: Mon, 20 Jun 2022 10:32:14 +0200 Subject: [PATCH 09/13] Restore docker-compose check in scripts --- helper-scripts/_cold-standby.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helper-scripts/_cold-standby.sh b/helper-scripts/_cold-standby.sh index b71d85cd5..7fc5a4957 100755 --- a/helper-scripts/_cold-standby.sh +++ b/helper-scripts/_cold-standby.sh @@ -258,7 +258,7 @@ echo "OK" -i "${REMOTE_SSH_KEY}" \ ${REMOTE_SSH_HOST} \ -p ${REMOTE_SSH_PORT} \ - $COMPOSE_COMMAND -f "${SCRIPT_DIR}/../docker-compose.yml" pull --no-parallel --quiet 2>&1 ; then + docker-compose -f "${SCRIPT_DIR}/../docker-compose.yml" pull --no-parallel --quiet 2>&1 ; then >&2 echo -e "\e[31m[ERR]\e[0m - Could not pull images on remote" fi From 452daf5d5eca1ba95d7e5befadf0ca8ab0dcab12 Mon Sep 17 00:00:00 2001 From: DerLinkman Date: Thu, 23 Jun 2022 08:55:06 +0200 Subject: [PATCH 10/13] Restored docker-compose Command --- helper-scripts/backup_and_restore.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helper-scripts/backup_and_restore.sh b/helper-scripts/backup_and_restore.sh index b45fcb97d..d6f11ca80 100755 --- a/helper-scripts/backup_and_restore.sh +++ b/helper-scripts/backup_and_restore.sh @@ -239,7 +239,7 @@ function restore() { continue else echo "Stopping mailcow..." - ${COMPOSE_COMMAND} -f ${COMPOSE_FILE} --env-file ${ENV_FILE} down + docker-compose -f ${COMPOSE_FILE} --env-file ${ENV_FILE} down fi #docker stop $(docker ps -qf name=mysql-mailcow) if [[ -d "${RESTORE_LOCATION}/mysql" ]]; then @@ -277,7 +277,7 @@ function restore() { sed -i --follow-symlinks "/DBROOT/c\DBROOT=${DBROOT}" ${SCRIPT_DIR}/../mailcow.conf source ${SCRIPT_DIR}/../mailcow.conf echo "Starting mailcow..." - ${COMPOSE_COMMAND} -f ${COMPOSE_FILE} --env-file ${ENV_FILE} up -d + docker-compose -f ${COMPOSE_FILE} --env-file ${ENV_FILE} up -d #docker start $(docker ps -aqf name=mysql-mailcow) fi ;; From db7d7ea288ca1ea85959890616dd1a694452acd2 Mon Sep 17 00:00:00 2001 From: DerLinkman Date: Thu, 23 Jun 2022 10:05:09 +0200 Subject: [PATCH 11/13] Added override NGINX Port Removal --- update.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/update.sh b/update.sh index dc47c3dee..104ef38e5 100755 --- a/update.sh +++ b/update.sh @@ -209,6 +209,26 @@ migrate_docker_nat() { fi } +remove_obsolete_nginx_ports() { + # Removing obsolete docker-compose.override.yml + if [ -s docker-compose.override.* ]; then + if cat docker-compose.override.* | grep nginx-mailcow > /dev/null 2>&1; then + if cat docker-compose.override.* | grep -w [::] > /dev/null 2>&1; then + if cat docker-compose.override.* | grep -w 80:80 > /dev/null 2>&1 && cat docker-compose.override.* | grep -w 443:443 > /dev/null 2>&1 ; then + sed -i '/nginx-mailcow:$/,/^$/d' docker-compose.override.* + if [[ "$(cat docker-compose.override.yml | sed '/^\s*$/d' | wc -l)" == "2" ]]; then + mv docker-compose.override.yml docker-compose.override.yml_backup + echo -e "\e[31mRemoved obsolete NGINX IPv6 Bind from override File.\e[0m" + elif [[ "$(cat docker-compose.override.yaml | sed '/^\s*$/d' | wc -l)" == "2" ]]; then + mv docker-compose.override.yaml docker-compose.override.yaml_backup + echo -e "\e[31mRemoved obsolete NGINX IPv6 Bind from override File.\e[0m" + fi + fi + fi + fi + fi +} + update_compose(){ if [[ ${NO_UPDATE_COMPOSE} == "y" ]]; then echo -e "\e[33mNot fetching latest docker-compose, please check for updates manually!\e[0m" @@ -635,6 +655,8 @@ fi update_compose +remove_obsolete_nginx_ports + echo -e "\e[32mValidating docker-compose stack configuration...\e[0m" if ! docker-compose config -q; then echo -e "\e[31m\nOh no, something went wrong. Please check the error message above.\e[0m" From 092890b6abca7e195d0742fbf644119c57439a70 Mon Sep 17 00:00:00 2001 From: DerLinkman Date: Thu, 23 Jun 2022 10:23:48 +0200 Subject: [PATCH 12/13] Changed message in nginx-port removal function --- update.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/update.sh b/update.sh index 104ef38e5..9836b9273 100755 --- a/update.sh +++ b/update.sh @@ -216,12 +216,13 @@ remove_obsolete_nginx_ports() { if cat docker-compose.override.* | grep -w [::] > /dev/null 2>&1; then if cat docker-compose.override.* | grep -w 80:80 > /dev/null 2>&1 && cat docker-compose.override.* | grep -w 443:443 > /dev/null 2>&1 ; then sed -i '/nginx-mailcow:$/,/^$/d' docker-compose.override.* + echo -e "\e[32mRemoved obsolete NGINX IPv6 Bind from override File.\e[0m" if [[ "$(cat docker-compose.override.yml | sed '/^\s*$/d' | wc -l)" == "2" ]]; then mv docker-compose.override.yml docker-compose.override.yml_backup - echo -e "\e[31mRemoved obsolete NGINX IPv6 Bind from override File.\e[0m" + echo -e "\e[31mdocker-compose.override.yml is empty. Renamed it to ensure mailcow is startable.\e[0m" elif [[ "$(cat docker-compose.override.yaml | sed '/^\s*$/d' | wc -l)" == "2" ]]; then mv docker-compose.override.yaml docker-compose.override.yaml_backup - echo -e "\e[31mRemoved obsolete NGINX IPv6 Bind from override File.\e[0m" + echo -e "\e[31mdocker-compose.override.yml is empty. Renamed it to ensure mailcow is startable.\e[0m" fi fi fi From 263baa81c07b2a3546ee6301d58eba511a8747fc Mon Sep 17 00:00:00 2001 From: DerLinkman Date: Thu, 23 Jun 2022 10:55:12 +0200 Subject: [PATCH 13/13] Improved .yml and .yaml check for Port Removal --- update.sh | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/update.sh b/update.sh index 9836b9273..714541aa4 100755 --- a/update.sh +++ b/update.sh @@ -211,23 +211,22 @@ migrate_docker_nat() { remove_obsolete_nginx_ports() { # Removing obsolete docker-compose.override.yml - if [ -s docker-compose.override.* ]; then - if cat docker-compose.override.* | grep nginx-mailcow > /dev/null 2>&1; then - if cat docker-compose.override.* | grep -w [::] > /dev/null 2>&1; then - if cat docker-compose.override.* | grep -w 80:80 > /dev/null 2>&1 && cat docker-compose.override.* | grep -w 443:443 > /dev/null 2>&1 ; then - sed -i '/nginx-mailcow:$/,/^$/d' docker-compose.override.* - echo -e "\e[32mRemoved obsolete NGINX IPv6 Bind from override File.\e[0m" - if [[ "$(cat docker-compose.override.yml | sed '/^\s*$/d' | wc -l)" == "2" ]]; then - mv docker-compose.override.yml docker-compose.override.yml_backup - echo -e "\e[31mdocker-compose.override.yml is empty. Renamed it to ensure mailcow is startable.\e[0m" - elif [[ "$(cat docker-compose.override.yaml | sed '/^\s*$/d' | wc -l)" == "2" ]]; then - mv docker-compose.override.yaml docker-compose.override.yaml_backup - echo -e "\e[31mdocker-compose.override.yml is empty. Renamed it to ensure mailcow is startable.\e[0m" + for override in docker-compose.override.yml docker-compose.override.yaml; do + if [ -s $override ] ; then + if cat $override | grep nginx-mailcow > /dev/null 2>&1; then + if cat $override | grep -w [::] > /dev/null 2>&1; then + if cat $override | grep -w 80:80 > /dev/null 2>&1 && cat $override | grep -w 443:443 > /dev/null 2>&1 ; then + sed -i '/nginx-mailcow:$/,/^$/d' $override + echo -e "\e[33mRemoved obsolete NGINX IPv6 Bind from override File.\e[0m" + if [[ "$(cat $override | sed '/^\s*$/d' | wc -l)" == "2" ]]; then + mv $override ${override}_backup + echo -e "\e[31m${override} is empty. Renamed it to ensure mailcow is startable.\e[0m" fi fi fi fi - fi + fi + done } update_compose(){