]> git.pld-linux.org Git - packages/spamassassin.git/blob - sa-update.sh
- rel 4; new way for configuring channels; use sought channel too; more suggests
[packages/spamassassin.git] / sa-update.sh
1 #!/bin/sh
2
3 umask 022
4 OPT=""
5
6 # sa-update must create keyring
7 if [ ! -d /etc/mail/spamassassin/sa-update-keys ]; then
8         sa-update
9 fi
10
11 # Initialize Channels and Keys
12 CHANNELLIST=""
13 KEYLIST=""
14 # Process each channel defined in /etc/mail/spamassassin/channel.d/
15 for file in /etc/mail/spamassassin/channel.d/*.conf; do
16     [ ! -f "$file" ] && continue
17     # Validate config file
18     PREFIXES="CHANNELURL KEYID BEGIN"
19     for prefix in $PREFIXES; do
20         if ! grep -q "$prefix" $file; then
21             echo "ERROR: $file missing $prefix"
22             exit 255
23         fi
24     done
25     . "$file"
26     #echo "CHANNELURL=$CHANNELURL"
27     #echo "KEYID=$KEYID"
28     CHANNELLIST="$CHANNELLIST $CHANNELURL"
29     KEYLIST="$KEYLIST $KEYID"
30     sa-update --import "$file"
31 done
32
33 [ -f /etc/mail/spamassassin/channels ] && OPT="$OPT --channelfile /etc/mail/spamassassin/channels"
34
35 # Run sa-update on each channel, restart spam daemon if success
36 for channel in $CHANNELLIST; do
37     OPT="$OPT --channel $channel"
38 done
39 for keyid in $KEYLIST; do
40     OPT="$OPT --gpgkey $keyid"
41 done
42
43 # Only restart spamd if sa-update returns 0, meaning it updated the rules
44 /usr/bin/sa-update $OPT || exit $?
45
46 if [ -x /usr/bin/sa-compile ]; then
47         out=$(/usr/bin/sa-compile 2>&1)
48         rc=$?
49         if [ $rc -gt 0 ]; then
50                 echo >&2 "$out"
51                 exit $rc
52         fi
53 fi
54
55 if [ -x /etc/rc.d/init.d/spamd -a -e /var/lock/subsys/spamd ]; then
56         /sbin/service spamd restart > /dev/null
57 fi
This page took 0.026372 seconds and 3 git commands to generate.