Files
docker-smtp/stretch/docker-entrypoint.sh

54 lines
1.5 KiB
Bash
Raw Normal View History

2018-07-11 11:58:52 +01:00
#!/bin/sh
set -e
CONFDIR=/etc/exim4
2018-07-11 15:35:42 +01:00
# By default, send email directly to the recipient.
2018-07-11 11:58:52 +01:00
DC_EXIMCONFIG_CONFIGTYPE="internet"
2018-07-11 15:35:42 +01:00
# By default, only hosts on the private network can use the smart host (ie,
# only other containers, not the whole internet); a thin layer of protection
# in case port 25 is accidentally exposed to the public internet.
DC_RELAY_NETS="10.0.0.0/8;172.16.0.0/12;192.168.0.0/16"
# Set smarthost.
2018-07-11 11:58:52 +01:00
if [ "x$RELAY_HOST" != "x" ]; then
DC_EXIMCONFIG_CONFIGTYPE="satellite"
DC_SMARTHOST="$RELAY_HOST::${RELAY_PORT:-25}"
if [ "x$RELAY_USERNAME" != "x" ] && [ "x$RELAY_PASSWORD" != "x" ]; then
printf '%s\n' "*:$RELAY_USERNAME:$RELAY_PASSWORD" > "$CONFDIR/passwd.client"
fi
fi
2018-07-11 15:35:42 +01:00
# Set which hosts can use the smart host.
if [ "x$RELAY_NETS" != "x" ]; then
DC_RELAY_NETS="$RELAY_NETS"
fi
2018-07-11 11:58:52 +01:00
# Write exim configuration.
cat << EOF > "$CONFDIR/update-exim4.conf.conf"
dc_eximconfig_configtype='$DC_EXIMCONFIG_CONFIGTYPE'
dc_other_hostnames=''
2018-07-11 15:11:48 +01:00
dc_local_interfaces=''
2018-07-11 11:58:52 +01:00
dc_readhost=''
2018-07-11 15:11:48 +01:00
dc_relay_domains=''
2018-07-11 11:58:52 +01:00
dc_minimaldns='false'
2018-07-11 15:35:42 +01:00
dc_relay_nets='$DC_RELAY_NETS'
2018-07-11 11:58:52 +01:00
dc_smarthost='${DC_SMARTHOST:-}'
CFILEMODE='644'
dc_use_split_config='false'
dc_hide_mailname='true'
dc_mailname_in_oh='true'
dc_localdelivery='mail_spool'
EOF
# Set primary_hostname.
if [ "x$MAILNAME" != "x" ]; then
printf '%s\n' "$MAILNAME" > /etc/mailname
printf '%s\n' "MAIN_HARDCODE_PRIMARY_HOSTNAME=$MAILNAME" >> "$CONFDIR/update-exim4.conf.conf"
fi
# Apply exim configuration.
update-exim4.conf
exec "$@"