From f7369f061105e3fc97482d611876c98b4da4df58 Mon Sep 17 00:00:00 2001 From: DerLinkman Date: Tue, 5 Jul 2022 12:07:10 +0200 Subject: [PATCH 01/10] [Update.sh] Added docker-compose Update prompt + Version check --- update.sh | 69 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 20 deletions(-) diff --git a/update.sh b/update.sh index ea283eb2..612ccfaf 100755 --- a/update.sh +++ b/update.sh @@ -40,25 +40,7 @@ PATH=$PATH:/opt/bin umask 0022 -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 -DATE=$(date +%Y-%m-%d_%H_%M_%S) -BRANCH=$(cd ${SCRIPT_DIR}; git rev-parse --abbrev-ref HEAD) +############## Begin Function Section ############## check_online_status() { CHECK_ONLINE_IPS=(1.1.1.1 9.9.9.9 8.8.8.8) @@ -241,6 +223,13 @@ 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 + if [ ! $FORCE ]; then + read -r -p "Do you want to update your docker-compose Version? It will automatic upgrade your docker-compose installation (recommended)? [y/N] " updatecomposeresponse + if [[ ! "${updatecomposeresponse}" =~ ^([yY][eE][sS]|[yY])+$ ]]; then + echo "OK, not updating docker-compose." + return 0 + fi + fi 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 @@ -277,6 +266,38 @@ else fi } +############## End Function Section ############## + +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. Please install it manually regarding to this doc site: https://mailcow.github.io/mailcow-dockerized-docs/i_u_m/i_u_m_install/" + sleep 3 + exit 1; + fi +done + +## Check if docker-compose >= v2 +if ! docker-compose version --short | grep "^2." > /dev/null 2>&1; then + echo -e "\e[33mYour docker-compose Version is not up to date!\e[0m" + echo -e "\e[33mmailcow needs docker-compose >= 2.5!\e[0m" + echo -e "\e[33mYour current installed Version: $(docker-compose version --short)\e[0m" + sleep 3 + update_compose + if [[ ! "${updatecomposeresponse}" =~ ^([yY][eE][sS]|[yY])+$ ]]; then + echo -e "\e[31mmailcow does not work with docker-compose <= 2.X anymore!\e[0m" + echo -e "\e[31mPlease update your docker-compose manually, to run mailcow.\e[0m" + echo -e "\e[31mExiting...\e[0m" + exit 1 + fi +fi + +export LC_ALL=C +DATE=$(date +%Y-%m-%d_%H_%M_%S) +BRANCH=$(cd ${SCRIPT_DIR}; git rev-parse --abbrev-ref HEAD) + while (($#)); do case "${1}" in --check|-c) @@ -657,7 +678,15 @@ if [ ! $FORCE ]; then migrate_docker_nat fi -update_compose +LATEST_COMPOSE=$(curl -#L https://www.servercow.de/docker-compose/latest.php) +COMPOSE_VERSION=$(docker-compose version --short) +if [[ "$LATEST_COMPOSE" != "$COMPOSE_VERSION" ]]; then + echo -e "\e[33mA new docker-compose Version is available: $LATEST_COMPOSE\e[0m" + echo -e "\e[33mYour Version is: $COMPOSE_VERSION\e[0m" + update_compose +else + echo -e "\e[32mYour docker-compose Version is up to date! Not updating it...\e[0m" +fi remove_obsolete_nginx_ports From d82cfc6c62427e2884ea8ec4da3db47205118dcd Mon Sep 17 00:00:00 2001 From: DerLinkman Date: Fri, 8 Jul 2022 10:43:44 +0200 Subject: [PATCH 02/10] Changed no compose warning color --- update.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/update.sh b/update.sh index 612ccfaf..e64c49e8 100755 --- a/update.sh +++ b/update.sh @@ -273,7 +273,8 @@ for bin in curl docker git awk sha1sum; do echo "Cannot find ${bin}, exiting..." exit 1; elif [[ -z $(which docker-compose) ]]; then - echo "Cannot find docker-compose Standalone. Please install it manually regarding to this doc site: https://mailcow.github.io/mailcow-dockerized-docs/i_u_m/i_u_m_install/" + echo -e "\e[31mCannot find docker-compose Standalone.\e[0m" + echo -e "\e[31mPlease install it manually regarding to this doc site: https://mailcow.github.io/mailcow-dockerized-docs/i_u_m/i_u_m_install/\e[0m" sleep 3 exit 1; fi From 385570c1e8aadd49b48134abf09a737fd0553554 Mon Sep 17 00:00:00 2001 From: DerLinkman Date: Fri, 8 Jul 2022 10:54:50 +0200 Subject: [PATCH 03/10] Fixed wrongly override_backup overwriting --- update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update.sh b/update.sh index e64c49e8..aef57e9d 100755 --- a/update.sh +++ b/update.sh @@ -205,7 +205,7 @@ remove_obsolete_nginx_ports() { sed -i '/nginx-mailcow:$/,/^$/d' $override echo -e "\e[33mRemoved obsolete NGINX IPv6 Bind from original override File.\e[0m" if [[ "$(cat $override | sed '/^\s*$/d' | wc -l)" == "2" ]]; then - mv $override ${override}_backup + mv $override ${override}_empty echo -e "\e[31m${override} is empty. Renamed it to ensure mailcow is startable.\e[0m" fi fi From 40cf2c85e609f2cb82f85841c16a749cf0748011 Mon Sep 17 00:00:00 2001 From: DerLinkman Date: Fri, 8 Jul 2022 13:48:31 +0200 Subject: [PATCH 04/10] Re-aranged the functions position to top --- update.sh | 100 +++++++++++++++++++++++++++--------------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/update.sh b/update.sh index aef57e9d..3e48fb1e 100755 --- a/update.sh +++ b/update.sh @@ -1,45 +1,5 @@ #!/usr/bin/env bash -# Check permissions -if [ "$(id -u)" -ne "0" ]; then - echo "You need to be root" - exit 1 -fi - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -# Run pre-update-hook -if [ -f "${SCRIPT_DIR}/pre_update_hook.sh" ]; then - bash "${SCRIPT_DIR}/pre_update_hook.sh" -fi - -if [[ "$(uname -r)" =~ ^4\.15\.0-60 ]]; then - echo "DO NOT RUN mailcow ON THIS UBUNTU KERNEL!"; - echo "Please update to 5.x or use another distribution." - exit 1 -fi - -if [[ "$(uname -r)" =~ ^4\.4\. ]]; then - if grep -q Ubuntu <<< $(uname -a); then - echo "DO NOT RUN mailcow ON THIS UBUNTU KERNEL!" - echo "Please update to linux-generic-hwe-16.04 by running \"apt-get install --install-recommends linux-generic-hwe-16.04\"" - exit 1 - fi - echo "mailcow on a 4.4.x kernel is not supported. It may or may not work, please upgrade your kernel or continue at your own risk." - read -p "Press any key to continue..." < /dev/tty -fi - -# Exit on error and pipefail -set -o pipefail - -# Setting high dc timeout -export COMPOSE_HTTP_TIMEOUT=600 - -# Add /opt/bin to PATH -PATH=$PATH:/opt/bin - -umask 0022 - ############## Begin Function Section ############## check_online_status() { @@ -268,6 +228,46 @@ fi ############## End Function Section ############## +# Check permissions +if [ "$(id -u)" -ne "0" ]; then + echo "You need to be root" + exit 1 +fi + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +# Run pre-update-hook +if [ -f "${SCRIPT_DIR}/pre_update_hook.sh" ]; then + bash "${SCRIPT_DIR}/pre_update_hook.sh" +fi + +if [[ "$(uname -r)" =~ ^4\.15\.0-60 ]]; then + echo "DO NOT RUN mailcow ON THIS UBUNTU KERNEL!"; + echo "Please update to 5.x or use another distribution." + exit 1 +fi + +if [[ "$(uname -r)" =~ ^4\.4\. ]]; then + if grep -q Ubuntu <<< $(uname -a); then + echo "DO NOT RUN mailcow ON THIS UBUNTU KERNEL!" + echo "Please update to linux-generic-hwe-16.04 by running \"apt-get install --install-recommends linux-generic-hwe-16.04\"" + exit 1 + fi + echo "mailcow on a 4.4.x kernel is not supported. It may or may not work, please upgrade your kernel or continue at your own risk." + read -p "Press any key to continue..." < /dev/tty +fi + +# Exit on error and pipefail +set -o pipefail + +# Setting high dc timeout +export COMPOSE_HTTP_TIMEOUT=600 + +# Add /opt/bin to PATH +PATH=$PATH:/opt/bin + +umask 0022 + for bin in curl docker git awk sha1sum; do if [[ -z $(which ${bin}) ]]; then echo "Cannot find ${bin}, exiting..." @@ -652,16 +652,16 @@ else fi 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 -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 2 -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 +# 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 2 +# fi if [[ -f mailcow.conf ]]; then source mailcow.conf From 43ec12f4f0a87db8440c20759bfe2e2a00bb4aa3 Mon Sep 17 00:00:00 2001 From: DerLinkman Date: Fri, 8 Jul 2022 13:49:33 +0200 Subject: [PATCH 05/10] Readded (again) the new update script check... --- update.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/update.sh b/update.sh index 3e48fb1e..c7c958a4 100755 --- a/update.sh +++ b/update.sh @@ -652,16 +652,16 @@ else fi 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 -# 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 2 -# 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 +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 2 +fi if [[ -f mailcow.conf ]]; then source mailcow.conf From b8ec244d92ea3a4118ffc389f0a4fb31c585458c Mon Sep 17 00:00:00 2001 From: DerLinkman Date: Wed, 13 Jul 2022 08:50:28 +0200 Subject: [PATCH 06/10] Modified pip compose check --- update.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/update.sh b/update.sh index c7c958a4..f02d0d7c 100755 --- a/update.sh +++ b/update.sh @@ -203,8 +203,12 @@ 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 + if [[ -z $(which pip) && $(pip list --local 2>&1 | grep -v DEPRECATION | grep -c docker-compose) == 1 ]]; then + echo -e "\e[33mFound a docker-compose Version installed with pip!\e[0m" + echo -e "\e[33mPlease uninstall the pip Version of docker-compose since it doesn´t support Versions higher than 1.29.2.\e[0m" + sleep 2 + echo -e "\e[33mExiting...\e[0m" + exit 1 #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) From 83b79edb423c7637650f93a4142c1cded304e391 Mon Sep 17 00:00:00 2001 From: DerLinkman Date: Wed, 13 Jul 2022 08:57:50 +0200 Subject: [PATCH 07/10] Fixed PIP Check --- update.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/update.sh b/update.sh index f02d0d7c..63c50f9f 100755 --- a/update.sh +++ b/update.sh @@ -203,9 +203,9 @@ 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 + if [[ ! $(which pip) && $(pip list --local 2>&1 | grep -v DEPRECATION | grep -c docker-compose) == 1 ]]; then echo -e "\e[33mFound a docker-compose Version installed with pip!\e[0m" - echo -e "\e[33mPlease uninstall the pip Version of docker-compose since it doesn´t support Versions higher than 1.29.2.\e[0m" + echo -e "\e[31mPlease uninstall the pip Version of docker-compose since it doesn´t support Versions higher than 1.29.2.\e[0m" sleep 2 echo -e "\e[33mExiting...\e[0m" exit 1 @@ -292,7 +292,7 @@ if ! docker-compose version --short | grep "^2." > /dev/null 2>&1; then sleep 3 update_compose if [[ ! "${updatecomposeresponse}" =~ ^([yY][eE][sS]|[yY])+$ ]]; then - echo -e "\e[31mmailcow does not work with docker-compose <= 2.X anymore!\e[0m" + echo -e "\e[31mmailcow does not work with docker-compose <= 2.X.X anymore!\e[0m" echo -e "\e[31mPlease update your docker-compose manually, to run mailcow.\e[0m" echo -e "\e[31mExiting...\e[0m" exit 1 From 65bb808441e4d86e01cf417aff0f36995c312f11 Mon Sep 17 00:00:00 2001 From: DerLinkman Date: Wed, 13 Jul 2022 11:02:41 +0200 Subject: [PATCH 08/10] Muted which Pip in update_compose --- update.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/update.sh b/update.sh index 63c50f9f..071888a7 100755 --- a/update.sh +++ b/update.sh @@ -203,7 +203,7 @@ else DC_DL_SUFFIX=legacy fi sleep 1 - if [[ ! $(which pip) && $(pip list --local 2>&1 | grep -v DEPRECATION | grep -c docker-compose) == 1 ]]; then + if [[ ! $(which pip 2>&1) && $(pip list --local 2>&1 | grep -v DEPRECATION | grep -c docker-compose) == 1 ]]; then echo -e "\e[33mFound a docker-compose Version installed with pip!\e[0m" echo -e "\e[31mPlease uninstall the pip Version of docker-compose since it doesn´t support Versions higher than 1.29.2.\e[0m" sleep 2 @@ -656,16 +656,16 @@ else fi 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 -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 2 -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 +# 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 2 +# fi if [[ -f mailcow.conf ]]; then source mailcow.conf From f07b9ea304af01caa4d991cd4896dc17602d2390 Mon Sep 17 00:00:00 2001 From: DerLinkman Date: Wed, 13 Jul 2022 15:08:31 +0200 Subject: [PATCH 09/10] Corrected pip check --- update.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/update.sh b/update.sh index 071888a7..d42c91d6 100755 --- a/update.sh +++ b/update.sh @@ -203,7 +203,7 @@ else DC_DL_SUFFIX=legacy fi sleep 1 - if [[ ! $(which pip 2>&1) && $(pip list --local 2>&1 | grep -v DEPRECATION | grep -c docker-compose) == 1 ]]; then + if [[ $(which pip 2>&1) && $(pip list --local 2>&1 | grep -v DEPRECATION | grep -c docker-compose) == 1 || $(which pip3 2>&1) && $(pip3 list --local 2>&1 | grep -v DEPRECATION | grep -c docker-compose) == 1 ]]; then echo -e "\e[33mFound a docker-compose Version installed with pip!\e[0m" echo -e "\e[31mPlease uninstall the pip Version of docker-compose since it doesn´t support Versions higher than 1.29.2.\e[0m" sleep 2 @@ -656,16 +656,16 @@ else fi 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 -# 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 2 -# 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 +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 2 +fi if [[ -f mailcow.conf ]]; then source mailcow.conf From 586b60b276aaf10942c2a78b5c76289802528a32 Mon Sep 17 00:00:00 2001 From: DerLinkman Date: Wed, 13 Jul 2022 15:13:14 +0200 Subject: [PATCH 10/10] Unspecified direct compose version (lower then 2.X.X) --- update.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/update.sh b/update.sh index d42c91d6..e3f3ad09 100755 --- a/update.sh +++ b/update.sh @@ -287,12 +287,12 @@ done ## Check if docker-compose >= v2 if ! docker-compose version --short | grep "^2." > /dev/null 2>&1; then echo -e "\e[33mYour docker-compose Version is not up to date!\e[0m" - echo -e "\e[33mmailcow needs docker-compose >= 2.5!\e[0m" + echo -e "\e[33mmailcow needs docker-compose > 2.X.X!\e[0m" echo -e "\e[33mYour current installed Version: $(docker-compose version --short)\e[0m" sleep 3 update_compose if [[ ! "${updatecomposeresponse}" =~ ^([yY][eE][sS]|[yY])+$ ]]; then - echo -e "\e[31mmailcow does not work with docker-compose <= 2.X.X anymore!\e[0m" + echo -e "\e[31mmailcow does not work with docker-compose < 2.X.X anymore!\e[0m" echo -e "\e[31mPlease update your docker-compose manually, to run mailcow.\e[0m" echo -e "\e[31mExiting...\e[0m" exit 1