From 3f141499dcf22dfe419c9a6c59bb167c59a9fc33 Mon Sep 17 00:00:00 2001 From: Christoph Date: Wed, 12 Mar 2025 14:43:41 +0100 Subject: [PATCH] install_postfix_base.sh: update file 'sasl_passwd' instead ao renewing it. --- install_postfix_base.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/install_postfix_base.sh b/install_postfix_base.sh index ea5862b..f8f4a02 100755 --- a/install_postfix_base.sh +++ b/install_postfix_base.sh @@ -1103,11 +1103,20 @@ echo_ok echononl " Configure SASL authentification" if $SASL_AUTH ; then + _sasl_pw_file="/etc/postfix/sasl_passwd" + if [[ -f "${_sasl_pw_file}" ]] && $(grep -q -E "^\[${RELAY_HOST}\]" ${_sasl_pw_file} 2> /dev/null); then + sed -i "/^\[${RELAY_HOST}/d" ${_sasl_pw_file} + if [[ "$?" != "0" ]]; then + error "Setting \"/etc/postfix/sasl_passwd\" failed! " + _failed=true + fi + fi + _failed=false if [[ ${RELAY_PORT} -ne 25 ]] ; then - echo "[$RELAY_HOST]:${RELAY_PORT} ${SASL_USER}@${RELAY_HOST}:$SASL_PASS" > /etc/postfix/sasl_passwd + echo "[$RELAY_HOST]:${RELAY_PORT} ${SASL_USER}@${RELAY_HOST}:$SASL_PASS" >> /etc/postfix/sasl_passwd else - echo "[$RELAY_HOST] ${SASL_USER}@${RELAY_HOST}:$SASL_PASS" > /etc/postfix/sasl_passwd + echo "[$RELAY_HOST] ${SASL_USER}@${RELAY_HOST}:$SASL_PASS" >> /etc/postfix/sasl_passwd fi if [[ "$?" != "0" ]]; then error "Setting \"/etc/postfix/sasl_passwd\" failed! "