forked from wader/postfix-relay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·48 lines (40 loc) · 1.41 KB
/
run
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
#!/bin/bash
# unclean container stop might leave pid files around and rsyslogd seems
# sometimes falsely think it's already running if some other process
# happens to have its old pid when starting.
rm -f \
/run/opendkim/opendkim.pid \
/run/rsyslogd.pid \
/var/spool/postfix/pid/master.pid
# POSTFIX_var env -> postconf -e var=$POSTFIX_var
for e in ${!POSTFIX_*} ; do postconf -e "${e:8}=${!e}" ; done
chown -R postfix:postfix /var/lib/postfix /var/mail /var/spool/postfix
# DKIM config
if [ ! -z "$OPENDKIM_DOMAINS" ] ; then
postconf -e milter_protocol=2
postconf -e milter_default_action=accept
postconf -e smtpd_milters=inet:localhost:12301
rm -f /etc/opendkim/KeyTable
rm -f /etc/opendkim/SigningTable
for d in $OPENDKIM_DOMAINS ; do
DIR="/etc/opendkim/keys/$d"
if [ ! -d "$DIR" ] ; then
mkdir -p "$DIR"
(cd "$DIR" && opendkim-genkey --selector=mail --domain=$d && chown opendkim:opendkim mail.private)
fi
echo "mail._domainkey.$d $d:mail:/etc/opendkim/keys/$d/mail.private" >> /etc/opendkim/KeyTable
echo "*@$d mail._domainkey.$d" >> /etc/opendkim/SigningTable
done
echo "DNS records:"
for d in $OPENDKIM_DOMAINS ; do
cat /etc/opendkim/keys/$d/mail.txt
done
fi
trap "service postfix stop; service opendkim stop; pkill -TERM rsyslogd" SIGTERM SIGINT
if [ ! -z "$OPENDKIM_DOMAINS" ] ; then
service opendkim start
fi
service postfix start
rsyslogd -n &
wait
exit 0