entrypoint
1.67 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
50
51
52
53
54
55
56
#!/bin/bash
set -ex
hostuser_home="$(getent passwd hostuser | cut -f 6 -d :)"
if [[ $GID ]]; then
old_gid=$(getent group hostgroup | cut -f 3 -d :)
groupmod -g $GID hostgroup
find "$hostuser_home" -gid $old_gid -print0 | xargs -0r chgrp hostgroup
fi
if [[ $UID ]]; then
usermod -u $UID hostuser
fi
HOSTNAME=$(hostname -f)
postconf -e \
"myhostname = ${POSTFIX_MAILNAME:-$HOSTNAME}" \
"myorigin = app" \
"mydestination = $HOSTNAME, localhost.localdomain, localhost, app" \
"mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 10.0.0.0/8 172.0.0.0/8 192.168.0.0/16"\
"inet_protocols = all" \
"relayhost = $POSTFIX_RELAYHOST" \
"virtual_maps = hash:/etc/postfix/virtual, regexp:/etc/postfix/virtual-regexp" \
"home_mailbox = Maildir/" \
&& true
: > /etc/postfix/virtual
postmap /etc/postfix/virtual
if [[ $POSTFIX_OVERRIDE_FROM ]]; then
postconf -e smtp_generic_maps=regexp:/etc/postfix/generic-regexp
echo "/^(root|hostuser)(\\+.*)?@[^.]+$/ $POSTFIX_OVERRIDE_FROM" > /etc/postfix/generic-regexp
else
postconf -e smtp_generic_maps=
fi
: ${POSTFIX_FORWARD_APP:=hostuser+app@localhost}
: ${POSTFIX_FORWARD_CATCHALL:=hostuser+catchall@localhost}
POSTFIX_FORWARD_APP_quoted="$(echo "$POSTFIX_FORWARD_APP" | sed 's/\([][\\+*.$^()]\)/\\\1/g')"
POSTFIX_FORWARD_CATCHALL_quoted="$(echo "$POSTFIX_FORWARD_CATCHALL" | sed 's/\([][\\+*.$^()]\)/\\\1/g')"
(
echo "/.+@app/ $POSTFIX_FORWARD_APP"
if [[ $POSTFIX_CATCHALL ]]; then
echo "if !/^($POSTFIX_FORWARD_APP_quoted|$POSTFIX_FORWARD_CATCHALL_quoted)/"
echo "/.+@.+/ $POSTFIX_FORWARD_CATCHALL"
echo "endif"
fi
) > /etc/postfix/virtual-regexp
cp /etc/resolv.conf /etc/services /var/spool/postfix/etc
/etc/init.d/rsyslog start
exec "$@"