2006-12-14 20:36:20 +00:00
|
|
|
#!/bin/bash
|
2009-09-25 04:15:56 +00:00
|
|
|
# *** DO NOT MODIFY THIS FILE ***
|
2009-12-28 06:42:03 +00:00
|
|
|
#
|
2010-01-11 22:51:02 +00:00
|
|
|
# /etc/mail/spamassassin/channel.d/*.conf
|
2009-12-29 03:18:05 +00:00
|
|
|
# Place files here to add custom channels.
|
2009-12-28 06:42:03 +00:00
|
|
|
#
|
2009-12-29 03:18:05 +00:00
|
|
|
|
2009-12-28 06:42:03 +00:00
|
|
|
# Proceed with sa-update if spam daemon is running or forced in /etc/sysconfig/sa-update
|
|
|
|
unset SAUPDATE
|
|
|
|
[ -f /etc/sysconfig/sa-update ] && . /etc/sysconfig/sa-update
|
|
|
|
for daemon in spamd amavisd; do
|
|
|
|
/sbin/pidof $daemon >& /dev/null
|
|
|
|
[ $? -eq 0 ] && SAUPDATE=yes
|
|
|
|
done
|
2010-01-14 22:29:40 +00:00
|
|
|
[ -f /var/run/mimedefang.pid ] && SAUPDATE=yes
|
2009-12-28 06:42:03 +00:00
|
|
|
|
|
|
|
# Skip sa-update if daemon not detected
|
|
|
|
[ -z "$SAUPDATE" ] && exit 0
|
|
|
|
|
2009-09-25 04:15:56 +00:00
|
|
|
# sa-update must create keyring
|
|
|
|
if [ ! -d /etc/mail/spamassassin/sa-update-keys ]; then
|
|
|
|
sa-update
|
|
|
|
fi
|
|
|
|
|
2009-12-29 03:18:05 +00:00
|
|
|
# Initialize Channels and Keys
|
|
|
|
CHANNELLIST=""
|
|
|
|
KEYLIST=""
|
2010-01-11 22:51:02 +00:00
|
|
|
# Process each channel defined in /etc/mail/spamassassin/channel.d/
|
2010-01-24 20:20:58 +00:00
|
|
|
for file in /etc/mail/spamassassin/channel.d/*.conf; do
|
|
|
|
[ ! -f "$file" ] && continue
|
2009-12-29 03:18:05 +00:00
|
|
|
# Validate config file
|
|
|
|
PREFIXES="CHANNELURL KEYID BEGIN"
|
|
|
|
for prefix in $PREFIXES; do
|
|
|
|
if ! grep -q "$prefix" $file; then
|
|
|
|
echo "ERROR: $file missing $prefix"
|
|
|
|
exit 255
|
|
|
|
fi
|
|
|
|
done
|
2010-01-24 20:20:58 +00:00
|
|
|
. "$file"
|
2010-03-11 20:15:26 +00:00
|
|
|
#echo "CHANNELURL=$CHANNELURL"
|
|
|
|
#echo "KEYID=$KEYID"
|
2009-12-29 03:18:05 +00:00
|
|
|
CHANNELLIST="$CHANNELLIST $CHANNELURL"
|
|
|
|
KEYLIST="$KEYLIST $KEYID"
|
2010-01-24 20:20:58 +00:00
|
|
|
sa-update --import "$file"
|
2009-12-29 03:18:05 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
# Sleep random amount of time before proceeding to avoid overwhelming the servers
|
|
|
|
sleep $(expr $RANDOM % 7200)
|
|
|
|
|
|
|
|
unset arglist
|
|
|
|
# Run sa-update on each channel, restart spam daemon if success
|
|
|
|
for channel in $CHANNELLIST; do
|
|
|
|
arglist="$arglist --channel $channel"
|
|
|
|
done
|
|
|
|
for keyid in $KEYLIST; do
|
|
|
|
arglist="$arglist --gpgkey $keyid"
|
|
|
|
done
|
|
|
|
/usr/bin/sa-update $arglist
|
|
|
|
if [ $? -eq 0 ]; then
|
2010-02-16 19:29:09 +00:00
|
|
|
/sbin/service spamassassin condrestart > /dev/null
|
|
|
|
[ -f /etc/init.d/amavisd ] && /sbin/service amavisd condrestart > /dev/null
|
|
|
|
[ -f /var/run/mimedefang.pid ] && /sbin/service mimedefang reload > /dev/null
|
2009-12-29 03:18:05 +00:00
|
|
|
fi
|