-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·49 lines (40 loc) · 2.47 KB
/
entrypoint.sh
File metadata and controls
executable file
·49 lines (40 loc) · 2.47 KB
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
#!/bin/sh
TX_SMTP_RELAY_HOST=${TX_SMTP_RELAY_HOST?Missing env var TX_SMTP_RELAY_HOST}
TX_SMTP_RELAY_MYHOSTNAME=${TX_SMTP_RELAY_MYHOSTNAME?Missing env var TX_SMTP_RELAY_MYHOSTNAME}
TX_SMTP_RELAY_USERNAME=${TX_SMTP_RELAY_USERNAME?Missing env var TX_SMTP_RELAY_USERNAME}
TX_SMTP_RELAY_PASSWORD=${TX_SMTP_RELAY_PASSWORD?Missing env var TX_SMTP_RELAY_PASSWORD}
TX_SMTP_RELAY_NETWORKS=${TX_SMTP_RELAY_NETWORKS:-10.0.0.0/8,127.0.0.0/8,172.17.0.0/16,192.0.0.0/8}
TX_SMTP_SASL_SECURITY_OPTIONS=${TX_SMTP_SASL_SECURITY_OPTIONS:-noanonymous, noplaintext}
TX_SMTP_SASL_TLS_SECURITY_OPTIONS=${TX_SMTP_SASL_TLS_SECURITY_OPTIONS:-noanonymous}
TX_SMTP_SASL_SECURITY_LEVEL=${TX_SMTP_SASL_SECURITY_LEVEL:-may}
echo "Setting configuration"
echo "TX_SMTP_RELAY_HOST - ${TX_SMTP_RELAY_HOST}"
echo "TX_SMTP_RELAY_MYHOSTNAME - ${TX_SMTP_RELAY_MYHOSTNAME}"
echo "TX_SMTP_RELAY_USERNAME - ${TX_SMTP_RELAY_USERNAME}"
echo "TX_SMTP_RELAY_PASSWORD - (hidden)"
echo "TX_SMTP_RELAY_NETWORKS - ${TX_SMTP_RELAY_NETWORKS}"
echo "TX_SMTP_SASL_SECURITY_OPTIONS - ${TX_SMTP_SASL_SECURITY_OPTIONS}"
echo "TX_SMTP_SASL_TLS_SECURITY_OPTIONS - ${TX_SMTP_SASL_TLS_SECURITY_OPTIONS}"
echo "TX_SMTP_SASL_SECURITY_LEVEL - ${TX_SMTP_SASL_SECURITY_LEVEL}"
# Write SMTP credentials
echo "${TX_SMTP_RELAY_HOST} ${TX_SMTP_RELAY_USERNAME}:${TX_SMTP_RELAY_PASSWORD}" > /etc/postfix/sasl_passwd || exit 1
postmap /etc/postfix/sasl_passwd || exit 1
rm /etc/postfix/sasl_passwd || exit 1
# Set configurations
postconf 'smtp_sasl_auth_enable = yes' || exit 1
postconf 'smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd' || exit 1
postconf "smtp_sasl_security_options = ${TX_SMTP_SASL_SECURITY_OPTIONS}" || exit 1
postconf "smtp_sasl_tls_security_options = ${TX_SMTP_SASL_TLS_SECURITY_OPTIONS}" || exit 1
postconf "smtp_tls_security_level = ${TX_SMTP_SASL_SECURITY_LEVEL}" || exit 1
# These are required
postconf "relayhost = ${TX_SMTP_RELAY_HOST}" || exit 1
postconf "myhostname = ${TX_SMTP_RELAY_MYHOSTNAME}" || exit 1
# Set allowed networks
postconf "mynetworks = ${TX_SMTP_RELAY_NETWORKS}" || exit 1
# http://www.postfix.org/COMPATIBILITY_README.html#smtputf8_enable
postconf 'smtputf8_enable = no' || exit 1
# This makes sure the message id is set. If this is set to no dkim=fail will happen.
postconf 'always_add_missing_headers = yes' || exit 1
# Have supervisord run and control postfix (/etc/supervisor.d/postfix.ini)
echo -e "\nLoading postfix service"
/usr/bin/supervisord -n