forked from macropin/docker-mailman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entry.sh
executable file
·67 lines (51 loc) · 1.96 KB
/
entry.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
#!/usr/bin/env bash
set -e
[ "$DEBUG" == 'true' ] && set -x
# Config checks
[ -z "$MAILMAN_URLHOST" ] && echo "Error: MAILMAN_URLHOST not set" && exit 128 || true
[ -z "$MAILMAN_EMAILHOST" ] && echo "Error: MAILMAN_EMAILHOST not set" && exit 128 || true
[ -z "$MAILMAN_ADMINMAIL" ] && echo "Error: MAILMAN_ADMINMAIL not set" && exit 128 || true
[ -z "$MAILMAN_ADMINPASS" ] && echo "Error: MAILMAN_ADMINPASS not set" && exit 128 || true
# Copy default mailman etc from cache
if [ ! "$(ls -A /etc/mailman)" ]; then
cp -a /etc/mailman.cache/. /etc/mailman/
fi
# Copy default mailman data from cache
if [ ! "$(ls -A /var/lib/mailman)" ]; then
cp -a /var/lib/mailman.cache/. /var/lib/mailman/
fi
# Copy default spool from cache
if [ ! "$(ls -A /var/spool/postfix)" ]; then
cp -a /var/spool/postfix.cache/. /var/spool/postfix/
fi
# Change defaults
sed -i \
-e "s|%DEFAULT_EMAIL_HOST%|$MAILMAN_EMAILHOST|" \
-e "s|%DEFAULT_URL_HOST%|$MAILMAN_URLHOST|" \
/etc/mailman/mm_cfg.py
# Fix permissions
/usr/lib/mailman/bin/check_perms -f
# If master list does not exist, create it
if [ ! -d /var/lib/mailman/lists/mailman ]; then
/var/lib/mailman/bin/newlist --quiet --urlhost=$MAILMAN_URLHOST --emailhost=$MAILMAN_EMAILHOST mailman $MAILMAN_ADMINMAIL $MAILMAN_ADMINPASS
fi
# Set mailman admin password
mmsitepass $MAILMAN_ADMINPASS
# Fix Postfix settings
postconf -e mydestination='$myhostname'
postconf -e myhostname=${HOSTNAME}
# 20MB size limit
postconf -e mailbox_size_limit=20971520
if [ -n "$MAILMAN_SSL_CRT" ] && [ -n "$MAILMAN_SSL_KEY" ] && [ -n "$MAILMAN_SSL_CA" ]; then
postconf -e smtpd_use_tls=yes
postconf -e smtpd_tls_cert_file=${MAILMAN_SSL_CRT}
postconf -e smtpd_tls_key_file=${MAILMAN_SSL_KEY}
postconf -e smtpd_tls_CAfile=${MAILMAN_SSL_CA}
fi
# Init Postfix Config
/usr/lib/mailman/bin/genaliases -q > /etc/aliases
newaliases
ln -s /usr/lib/mailman/bin/mailmanctl /etc/init.d/mailman
mkdir /var/run/mailman
chown list:list /var/run/mailman
exec $@