gcc484perl-5.22
Last change
on this file since 072d3d5 was
c5c522c,
checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago
|
initial commit, transferred from cleaned syn3 svn tree
|
-
Property mode set to
100755
|
File size:
1.3 KB
|
Line | |
---|
1 | #!/bin/bash |
---|
2 | |
---|
3 | USER="$1" |
---|
4 | SENDER="$2" |
---|
5 | INMAIL=/tmp/syn3-dagent.$$ |
---|
6 | SCANMAIL=/tmp/syn3-dagent-scanned.$$ |
---|
7 | |
---|
8 | |
---|
9 | #cleanup and exit |
---|
10 | end() |
---|
11 | { |
---|
12 | rm $INMAIL 2>/dev/null |
---|
13 | rm $SCANMAIL 2>/dev/null |
---|
14 | exit $1 |
---|
15 | } |
---|
16 | |
---|
17 | #check if user exists or fail permanent |
---|
18 | #(id will generate a nice error message) |
---|
19 | id "$USER" >/dev/null || end 100 |
---|
20 | |
---|
21 | #store mail temporary |
---|
22 | cat > $INMAIL || end 1 |
---|
23 | |
---|
24 | #pipe trough personal spamfilter of this user |
---|
25 | if ! grep "VIRUS.*IN MAIL TO YOU" $INMAIL >/dev/null && /usr/bin/dspamc --user "$USER" --deliver=innocent,spam --mail-from="$SENDER" --stdout >$SCANMAIL <$INMAIL; then |
---|
26 | #it worked |
---|
27 | if grep "^X-DSPAM-Result: Spam" $SCANMAIL >/dev/null; then |
---|
28 | SPAM=1 |
---|
29 | else |
---|
30 | SPAM= |
---|
31 | fi |
---|
32 | MAIL=$SCANMAIL |
---|
33 | else |
---|
34 | #spam filter is broken, or it was just a virus notification |
---|
35 | MAIL=$INMAIL |
---|
36 | SPAM= |
---|
37 | fi |
---|
38 | |
---|
39 | #check cyrus is up, and deliver it there: |
---|
40 | if /usr/bin/pgrep -f -x /usr/cyrus/bin/master ; then |
---|
41 | if [ "$SPAM" ]; then |
---|
42 | /usr/cyrus/bin/deliver -a "$USER" -m Spam "$USER" < $MAIL |
---|
43 | end $? |
---|
44 | else |
---|
45 | /usr/cyrus/bin/deliver -a "$USER" "$USER" < $MAIL |
---|
46 | end $? |
---|
47 | fi |
---|
48 | fi |
---|
49 | |
---|
50 | #check zarafa is up, and deliver it there: |
---|
51 | if pidof zarafa-server >/dev/null; then |
---|
52 | if [ "$SPAM" ]; then |
---|
53 | /usr/bin/zarafa-dagent "$USER" -q -j < $MAIL |
---|
54 | end $? |
---|
55 | else |
---|
56 | /usr/bin/zarafa-dagent "$USER" -q < $MAIL |
---|
57 | end $? |
---|
58 | fi |
---|
59 | fi |
---|
60 | |
---|
61 | #no backend mailstorage up, so fail temporary |
---|
62 | echo "All mailbackends are down, retry again later..." |
---|
63 | end 1 |
---|
Note: See
TracBrowser
for help on using the repository browser.