spamassassin/sa-update.cronscript

35 lines
1.2 KiB
Plaintext
Raw Normal View History

#!/bin/bash
# *** DO NOT MODIFY THIS FILE ***
#
# /etc/mail/spamassassin/sa-update-channels.txt
# Specify custom channels here
#
# /etc/mail/spamassassin/sa-update-keys.txt
# Specify trusted GPG keys for custom channels here
# 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
# Skip sa-update if daemon not detected
[ -z "$SAUPDATE" ] && exit 0
# Sleep random amount of time before proceeding to avoid overwhelming the servers
sleep $(expr $RANDOM % 7200)
# sa-update must create keyring
if [ ! -d /etc/mail/spamassassin/sa-update-keys ]; then
sa-update
fi
# Import SOUGHT key
sa-update --import /usr/share/spamassassin/sought-pubkey.txt
# Update rules with sa-update, restart spamd if rules were updated
/usr/bin/sa-update --channelfile /etc/mail/spamassassin/sa-update-channels.txt \
--gpgkeyfile /etc/mail/spamassassin/sa-update-keys.txt && \
/etc/init.d/spamassassin condrestart > /dev/null