-
Notifications
You must be signed in to change notification settings - Fork 199
/
entrypoint.sh
84 lines (75 loc) · 2.68 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
set -e
# Initialize localmacros as an empty file
echo -n "" > /etc/exim4/exim4.conf.localmacros
if [ "$MAILNAME" ]; then
echo "MAIN_HARDCODE_PRIMARY_HOSTNAME = $MAILNAME" > /etc/exim4/exim4.conf.localmacros
echo $MAILNAME > /etc/mailname
fi
if [ "$KEY_PATH" -a "$CERTIFICATE_PATH" ]; then
if [ "$MAILNAME" ]; then
echo "MAIN_TLS_ENABLE = yes" >> /etc/exim4/exim4.conf.localmacros
else
echo "MAIN_TLS_ENABLE = yes" >> /etc/exim4/exim4.conf.localmacros
fi
cp $KEY_PATH /etc/exim4/exim.key
cp $CERTIFICATE_PATH /etc/exim4/exim.crt
chgrp Debian-exim /etc/exim4/exim.key
chgrp Debian-exim /etc/exim4/exim.crt
chmod 640 /etc/exim4/exim.key
chmod 640 /etc/exim4/exim.crt
fi
opts=(
dc_local_interfaces "[${BIND_IP:-0.0.0.0}]:${PORT:-25} ; [${BIND_IP6:-::0}]:${PORT:-25}"
dc_other_hostnames "${OTHER_HOSTNAMES}"
dc_relay_nets "$(ip addr show dev eth0 | awk '$1 == "inet" { print $2 }' | xargs | sed 's/ /:/g')${RELAY_NETWORKS}"
)
if [ "$DISABLE_IPV6" ]; then
echo 'disable_ipv6=true' >> /etc/exim4/exim4.conf.localmacros
fi
if [ "$GMAIL_USER" -a "$GMAIL_PASSWORD" ]; then
opts+=(
dc_eximconfig_configtype 'smarthost'
dc_smarthost 'smtp.gmail.com::587'
dc_relay_domains "${RELAY_DOMAINS}"
)
echo "*.gmail.com:$GMAIL_USER:$GMAIL_PASSWORD" > /etc/exim4/passwd.client
elif [ "$SES_USER" -a "$SES_PASSWORD" ]; then
opts+=(
dc_eximconfig_configtype 'smarthost'
dc_smarthost "email-smtp.${SES_REGION:=us-east-1}.amazonaws.com::${SES_PORT:=587}"
dc_relay_domains "${RELAY_DOMAINS}"
)
echo "*.amazonaws.com:$SES_USER:$SES_PASSWORD" > /etc/exim4/passwd.client
# Allow to specify an arbitrary smarthost.
# Parameters: SMARTHOST_USER, SMARTHOST_PASSWORD: authentication parameters
# SMARTHOST_ALIASES: list of aliases to puth auth data for (semicolon separated)
# SMARTHOST_ADDRESS, SMARTHOST_PORT: connection parameters.
elif [ "$SMARTHOST_ADDRESS" ] ; then
opts+=(
dc_eximconfig_configtype 'smarthost'
dc_smarthost "${SMARTHOST_ADDRESS}::${SMARTHOST_PORT-25}"
dc_relay_domains "${RELAY_DOMAINS}"
)
rm -f /etc/exim4/passwd.client
if [ "$SMARTHOST_ALIASES" -a "$SMARTHOST_USER" -a "$SMARTHOST_PASSWORD" ] ; then
echo "$SMARTHOST_ALIASES;" | while read -d ";" alias; do
echo "${alias}:$SMARTHOST_USER:$SMARTHOST_PASSWORD" >> /etc/exim4/passwd.client
done
fi
elif [ "$RELAY_DOMAINS" ]; then
opts+=(
dc_relay_domains "${RELAY_DOMAINS}"
dc_eximconfig_configtype 'internet'
)
else
opts+=(
dc_eximconfig_configtype 'internet'
)
fi
# allow to add additional macros by bind-mounting a file
if [ -f /etc/exim4/_docker_additional_macros ]; then
cat /etc/exim4/_docker_additional_macros >> /etc/exim4/exim4.conf.localmacros
fi
/bin/set-exim4-update-conf "${opts[@]}"
exec "$@"