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! "