forked from rbicker/docker-isbg
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathentrypoint.sh
executable file
·78 lines (67 loc) · 1.78 KB
/
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
# get ham- and spamboxes
IFS=',' read -r -a learnhamboxes <<< "$LEARNHAMBOXES"
IFS=',' read -r -a learnspamboxes <<< "$LEARNSPAMBOXES"
# run spamd
/usr/sbin/spamd -d -D --allow-tell --create-prefs --max-children 5 --helper-home-dir #-u appuser -g appuser -p 7783
# counter for updating spam rules
i=11
# loop
while true; do
# check spamd status
ps aux |grep spamd |grep -q -v grep
if [ $? -ne 0 ]; then
echo "error: spamd does not seem to be running"
exit 1
fi
# every hour
if [ $i -le 0 ]; then
# update spam assassin rules
sa-update
sa-update --nogpg --channel spamassassin.heinlein-support.de
i=11
fi
# display all available folders
echo "IMAP FOLDER LIST"
isbg --imaphost="$IMAPHOST" --imapuser="$IMAPUSER" --imappasswd="$IMAPPASSWD" --imaplist
# learn all hamboxes
for box in "${learnhamboxes[@]}"; do
isbg \
--imaphost="$IMAPHOST" \
--imapuser="$IMAPUSER" \
--imappasswd="$IMAPPASSWD" \
--spamc \
--noninteractive \
--trackfile="/track/$TRACKFILE" \
--learnhambox="$box" \
--teachonly \
--spaminbox="$SPAMINBOX"
done
# learn all spamboxes
for box in "${learnspamboxes[@]}"; do
isbg \
--imaphost="$IMAPHOST" \
--imapuser="$IMAPUSER" \
--imappasswd="$IMAPPASSWD" \
--spamc \
--noninteractive \
--trackfile="/track/$TRACKFILE" \
--learnspambox="$box" \
--learnthendestroy \
--teachonly \
--spaminbox="$SPAMINBOX"
done
isbg \
--imaphost="$IMAPHOST" \
--imapuser="$IMAPUSER" \
--imappasswd="$IMAPPASSWD" \
--spamc \
--noninteractive \
--trackfile="/track/$TRACKFILE" \
--noreport \
--spaminbox="$SPAMINBOX"
# decrease counter
((i=i-1))
# sleep for 5 minutes
sleep 30
done