Skip to content

Commit

Permalink
add SASL_RELAYHOST to overwrite RELATHOST in sasl_passwd file on dema…
Browse files Browse the repository at this point in the history
…nd (bokysan#77)
  • Loading branch information
msvechla authored Jun 4, 2021
1 parent e0f7636 commit 02b1caa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ To change the log format, set the (unsurprisingly named) variable `LOG_FORMAT=js
### Postfix-specific options

* `RELAYHOST` = Host that relays your messages
* `SASL_RELAYHOST` = (optional) Relay Host referenced in the `sasl_passwd` file. Defaults to the value of `RELAYHOST`
* `RELAYHOST_USERNAME` = An (optional) username for the relay server
* `RELAYHOST_PASSWORD` = An (optional) login password for the relay server
* `RELAYHOST_PASSWORD_FILE` = An (optional) file containing the login password for the relay server. Mutually exclusive with the previous option.
Expand Down
1 change: 1 addition & 0 deletions helm/mail/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ config:
# ALLOW_EMPTY_SENDER_DOMAINS:
# LOG_FORMAT:
# RELAYHOST:
# SASL_RELAYHOST: # when specified overwrites the RELAYHOST in the sasl_passwd file
# RELAYHOST_USERNAME:
# RELAYHOST_PASSWORD:
# MASQUERADED_DOMAINS:
Expand Down
13 changes: 9 additions & 4 deletions scripts/common-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,20 @@ postfix_setup_relayhost() {

file_env 'RELAYHOST_PASSWORD'

# Allow to overwrite RELAYHOST in the sasl_passwd file with SASL_RELAYHOST variable if specified
if [ -z "$SASL_RELAYHOST" ]; then
SASL_RELAYHOST=$RELAYHOST
fi

if [ -n "$RELAYHOST_USERNAME" ] && [ -n "$RELAYHOST_PASSWORD" ]; then
echo -e " using username ${emphasis}$RELAYHOST_USERNAME${reset} and password ${emphasis}(redacted)${reset}."
if [[ -f /etc/postfix/sasl_passwd ]]; then
if ! grep -F "$RELAYHOST $RELAYHOST_USERNAME:$RELAYHOST_PASSWORD" /etc/postfix/sasl_passwd; then
sed -i -e "s/^$RELAYHOST .*$/d" /etc/postfix/sasl_passwd
echo "$RELAYHOST $RELAYHOST_USERNAME:$RELAYHOST_PASSWORD" >> /etc/postfix/sasl_passwd
if ! grep -F "$SASL_RELAYHOST $RELAYHOST_USERNAME:$RELAYHOST_PASSWORD" /etc/postfix/sasl_passwd; then
sed -i -e "s/^$SASL_RELAYHOST .*$/d" /etc/postfix/sasl_passwd
echo "$SASL_RELAYHOST $RELAYHOST_USERNAME:$RELAYHOST_PASSWORD" >> /etc/postfix/sasl_passwd
fi
else
echo "$RELAYHOST $RELAYHOST_USERNAME:$RELAYHOST_PASSWORD" >> /etc/postfix/sasl_passwd
echo "$SASL_RELAYHOST $RELAYHOST_USERNAME:$RELAYHOST_PASSWORD" >> /etc/postfix/sasl_passwd
fi
postmap lmdb:/etc/postfix/sasl_passwd
chown root:root /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.lmdb
Expand Down

0 comments on commit 02b1caa

Please sign in to comment.