source: npl/mailserver/netqmail_conf/root/usr/bin/syn3-dagent @ 4d0b1ea

gcc484perl-5.22
Last change on this file since 4d0b1ea was 4f7cda5, checked in by Edwin Eefting <edwin@datux.nl>, 7 years ago

upgrade to netqmail 1.06 with Roberto Puzzanghera's patch (http://notes.sagredo.eu/en/qmail-notes-185/patching-qmail-82.html)

  • Property mode set to 100755
File size: 1.8 KB
Line 
1#!/bin/bash
2
3USER="$1"
4SENDER="$2"
5INMAIL=/tmp/syn3-dagent.$$
6SCANMAIL=/tmp/syn3-dagent-scanned.$$
7
8
9#cleanup and exit
10end()
11{
12        rm $INMAIL 2>/dev/null
13        rm $SCANMAIL 2>/dev/null
14        exit $1
15}
16
17# some kind of ldap problem, try again later
18id "Administrator" >/dev/null || end 111
19
20#does the user exists?
21if ! id "$USER" >/dev/null; then
22        #we're sure theres no ldap problem?
23        id "Administrator" >/dev/null || end 111
24        #probably a bounce spammer, drop mail silently
25        echo "User does not exist, dropping mail."
26        end 0
27fi
28
29#store mail temporary
30cat > $INMAIL || end 1
31
32#pipe trough personal spamfilter of this user
33if ! grep "VIRUS.*IN MAIL TO YOU" $INMAIL >/dev/null && /usr/bin/dspamc --user "$USER" --deliver=innocent,spam --mail-from="$SENDER" --stdout >$SCANMAIL <$INMAIL; then
34        #it worked
35        if grep "^X-DSPAM-Result: Spam" $SCANMAIL >/dev/null; then
36                SPAM=1
37        else
38                SPAM=
39        fi
40        MAIL=$SCANMAIL
41else
42        #spam filter is broken, or it was just a virus notification
43        MAIL=$INMAIL
44        SPAM=
45fi
46
47# #check cyrus is up, and deliver it there:
48# if /usr/bin/pgrep -f -x /usr/cyrus/bin/master ; then
49#       if [ "$SPAM" ]; then
50#               /usr/cyrus/bin/deliver -a "$USER" -m Spam "$USER" < $MAIL
51#               end $?
52#       else
53#               /usr/cyrus/bin/deliver -a "$USER" "$USER" < $MAIL
54#               end $?
55#       fi
56# fi
57
58#check zarafa is up, and deliver it there:
59if pidof zarafa-server >/dev/null; then
60        if [ "$SPAM" ]; then
61                /usr/bin/zarafa-dagent "$USER" -q -j < $MAIL
62                end $?
63        else
64                /usr/bin/zarafa-dagent "$USER" -q < $MAIL
65                end $?
66        fi
67fi
68
69#check kopano is up, and deliver it there:
70if pidof kopano-server >/dev/null; then
71        if [ "$SPAM" ]; then
72                /usr/bin/kopano-dagent "$USER" -q -j < $MAIL
73                end $?
74        else
75                /usr/bin/kopano-dagent "$USER" -q < $MAIL
76                end $?
77        fi
78fi
79
80#no backend mailstorage up, so fail temporary
81echo "All mailbackends are down, retry again later..."
82end 111
Note: See TracBrowser for help on using the repository browser.