From 05a5f9e84a4bbc24824d7cf5009307ab71dc9af7 Mon Sep 17 00:00:00 2001 From: Maxim Baz Date: Sun, 20 Sep 2020 22:07:37 +0200 Subject: [PATCH] Support mailcow.conf being a symlink (#3770) * Support mailcow.conf being a symlink * Detect BusyBox sed in update.sh --- helper-scripts/backup_and_restore.sh | 8 ++++---- update.sh | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/helper-scripts/backup_and_restore.sh b/helper-scripts/backup_and_restore.sh index 231d0742..42546bac 100755 --- a/helper-scripts/backup_and_restore.sh +++ b/helper-scripts/backup_and_restore.sh @@ -251,10 +251,10 @@ function restore() { fi echo "Modifying mailcow.conf..." source ${RESTORE_LOCATION}/mailcow.conf - sed -i "/DBNAME/c\DBNAME=${DBNAME}" ${SCRIPT_DIR}/../mailcow.conf - sed -i "/DBUSER/c\DBUSER=${DBUSER}" ${SCRIPT_DIR}/../mailcow.conf - sed -i "/DBPASS/c\DBPASS=${DBPASS}" ${SCRIPT_DIR}/../mailcow.conf - sed -i "/DBROOT/c\DBROOT=${DBROOT}" ${SCRIPT_DIR}/../mailcow.conf + sed -i --follow-symlinks "/DBNAME/c\DBNAME=${DBNAME}" ${SCRIPT_DIR}/../mailcow.conf + sed -i --follow-symlinks "/DBUSER/c\DBUSER=${DBUSER}" ${SCRIPT_DIR}/../mailcow.conf + sed -i --follow-symlinks "/DBPASS/c\DBPASS=${DBPASS}" ${SCRIPT_DIR}/../mailcow.conf + sed -i --follow-symlinks "/DBROOT/c\DBROOT=${DBROOT}" ${SCRIPT_DIR}/../mailcow.conf source ${SCRIPT_DIR}/../mailcow.conf echo "Starting mailcow..." docker-compose up -d diff --git a/update.sh b/update.sh index 054eb387..79d9f15c 100755 --- a/update.sh +++ b/update.sh @@ -181,6 +181,7 @@ fi if grep --help 2>&1 | head -n 1 | grep -q -i "busybox"; then echo "BusybBox grep detected, please install gnu grep, \"apk add --no-cache --upgrade grep\""; exit 1; fi if cp --help 2>&1 | head -n 1 | grep -q -i "busybox"; then echo "BusybBox cp detected, please install coreutils, \"apk add --no-cache --upgrade coreutils\""; exit 1; fi +if sed --help 2>&1 | head -n 1 | grep -q -i "busybox"; then echo "BusybBox sed detected, please install gnu sed, \"apk add --no-cache --upgrade sed\""; exit 1; fi CONFIG_ARRAY=( "SKIP_LETS_ENCRYPT" @@ -215,7 +216,7 @@ CONFIG_ARRAY=( "REDIS_PORT" ) -sed -i '$a\' mailcow.conf +sed -i --follow-symlinks '$a\' mailcow.conf for option in ${CONFIG_ARRAY[@]}; do if [[ ${option} == "ADDITIONAL_SAN" ]]; then if ! grep -q ${option} mailcow.conf; then @@ -525,7 +526,7 @@ if grep -q 'SYSCTL_IPV6_DISABLED=1' mailcow.conf; then fi # Checking for old project name bug -sed -i 's#COMPOSEPROJECT_NAME#COMPOSE_PROJECT_NAME#g' mailcow.conf +sed -i --follow-symlinks 's#COMPOSEPROJECT_NAME#COMPOSE_PROJECT_NAME#g' mailcow.conf # Fix Rspamd maps if [ -f data/conf/rspamd/custom/global_from_blacklist.map ]; then