forked from erebe/personal-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-entrypoint.sh
executable file
·65 lines (53 loc) · 1.61 KB
/
docker-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
#!/bin/sh
# postfix-wrapper.sh, version 0.1.0
#
# You cannot start postfix in some foreground mode and
# it's more or less important that docker doesn't kill
# postfix and its chilren if you stop the container.
#
# Use this script with supervisord and it will take
# care about starting and stopping postfix correctly.
#
# supervisord config snippet for postfix-wrapper:
#
# [program:postfix]
# process_name = postfix
# command = /path/to/postfix-wrapper.sh
# startsecs = 0
# autorestart = false
#
trap "postfix stop" SIGINT
trap "postfix stop" SIGTERM
trap "postfix reload" SIGHUP
# force new copy of hosts there (otherwise links could be outdated)
#cp /etc/hosts /var/spool/postfix/etc/hosts
mail_filter_url=$(curl -s https://api.github.com/repos/erebe/hmailfilter/releases/latest | grep browser_download_url | cut -d '"' -f 4)
curl -L -o hmailclassifier $mail_filter_url
chmod +x hmailclassifier
# Give right to the data volume
chown erebe:erebe -R /data
cp /etc/fetchmail/fetchmailrc /home/erebe/
chmod 600 /home/erebe/fetchmailrc
# Start spamassassin
spamd -d -s stderr 2>/dev/null
# start postfix
postfix start
# lets give postfix some time to start
sleep 3
counter=-1
# wait until postfix is dead (triggered by trap)
while kill -0 "`cat /var/spool/postfix/pid/master.pid | sed 's/ //g'`"; do
counter=$(($counter + 1))
# Fetch mail from fallback mail server every 15min
if [ $(( $counter % 30 )) -eq 0 ]
then
fetchmail --nodetach --nosyslog --ssl -f /home/erebe/fetchmailrc
fi
# Update spamassassin filter every 12hours
if [ $(( $counter % 1440 )) -eq 0 ]
then
sa-update
counter=0
fi
sleep 30
done