]> git.pld-linux.org Git - packages/spamassassin.git/blame - sa-update.sh
- rel 4; new way for configuring channels; use sought channel too; more suggests
[packages/spamassassin.git] / sa-update.sh
CommitLineData
4f43e117
ER
1#!/bin/sh
2
85b132c6 3umask 022
aac421e4
AM
4OPT=""
5
384339c3
AM
6# sa-update must create keyring
7if [ ! -d /etc/mail/spamassassin/sa-update-keys ]; then
8 sa-update
9fi
10
11# Initialize Channels and Keys
12CHANNELLIST=""
13KEYLIST=""
14# Process each channel defined in /etc/mail/spamassassin/channel.d/
15for 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"
31done
32
aac421e4
AM
33[ -f /etc/mail/spamassassin/channels ] && OPT="$OPT --channelfile /etc/mail/spamassassin/channels"
34
384339c3
AM
35# Run sa-update on each channel, restart spam daemon if success
36for channel in $CHANNELLIST; do
37 OPT="$OPT --channel $channel"
38done
39for keyid in $KEYLIST; do
40 OPT="$OPT --gpgkey $keyid"
41done
42
4f43e117 43# Only restart spamd if sa-update returns 0, meaning it updated the rules
aac421e4 44/usr/bin/sa-update $OPT || exit $?
4f43e117
ER
45
46if [ -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
53fi
54
aac421e4 55if [ -x /etc/rc.d/init.d/spamd -a -e /var/lock/subsys/spamd ]; then
4f43e117
ER
56 /sbin/service spamd restart > /dev/null
57fi
This page took 0.030542 seconds and 4 git commands to generate.