mirror of
https://github.com/jessfraz/dockerfiles.git
synced 2025-12-12 16:02:40 +01:00
51 lines
1.2 KiB
Bash
Executable File
51 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
# Do we want to modify the config first with the script?
|
|
[ -f /etc/service/postfix/run.config ] && source /etc/service/postfix/run.config
|
|
|
|
if [ "$MAILNAME" ]; then
|
|
echo "$MAILNAME" > /etc/mailname
|
|
postconf -e myhostname="$MAILNAME"
|
|
fi
|
|
|
|
if [ "$MY_NETWORKS" ]; then
|
|
postconf -e mynetworks="$MY_NETWORKS"
|
|
fi
|
|
|
|
if [ "$MY_DESTINATION" ]; then
|
|
postconf -e mydestination="$MY_DESTINATION"
|
|
fi
|
|
|
|
if [ "$ROOT_ALIAS" ]; then
|
|
sed -i '/^root:/d' /etc/aliases
|
|
echo "root: $ROOT_ALIAS" >> /etc/aliases
|
|
newaliases
|
|
fi
|
|
|
|
if [ "$RELAY" ]; then
|
|
# setup the relay
|
|
echo "relay_host = $RELAY" >> /etc/postfix/main.cf
|
|
fi
|
|
|
|
if [ "$SASL_AUTH" ]; then
|
|
# setup tls
|
|
echo -e "smtp_sasl_auth_enable = yes\nsmtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd\nsmtp_sasl_security_options = noanonymous\nsmtp_use_tls = yes" >> /etc/postfix/main.cf
|
|
# generate the SASL password map
|
|
cat > /etc/postfix/sasl_passwd <<- EOF
|
|
$RELAY $SASL_AUTH
|
|
EOF
|
|
|
|
# generate a .db file
|
|
postmap /etc/postfix/sasl_passwd
|
|
|
|
# cleanup
|
|
rm /etc/postfix/sasl_passwd
|
|
|
|
# set permissions
|
|
chmod 600 /etc/postfix/sasl_passwd.db
|
|
fi
|
|
|
|
exec /usr/lib/postfix/master -c /etc/postfix -d 2>&1
|
|
tail -F /var/log/mail.log
|