Spamassassin update script

From Ye Ole Stash
Jump to: navigation, search
#Fun quick hacks ..because they might be fun..sometimes
 
host=`hostname`
spamhome=/etc/mail/spamassassin/
enablemalware=1 #set to 0 if you want to turn this off
sachannelsfile=/etc/mail/spamassassin/channels
supportemail=foo@foodomain.foo
 
 
if [ "$enablemalware" == 1 ];then
    /usr/bin/wget -qO $spamhome/malwareblocklist.cf http://www.malware.com.br/cgi/submit?action=list_sa
    /usr/bin/wget -qO $spamhome/malware.cf http://www.malware.com.br/cgi/submit?action=list_sa
         if [ "$?" -ne 0 ];
             then echo "SpamAssassin malwareblocklist download failed on $host" |mail -s "SpamassassinIssue on $host" engineering@worldspice.net
         fi
fi
 
echo "running updates"
 
/usr/bin/sa-update --nogpg --channelfile $sachannelsfile #if you have gpg setup remove --nogpg I RECOMMEND USING GPG but have this here for those that want something simple. 
 
if [ "$?" -gt 3 ];
    then echo "SpamAssassin Update failed on $host" |mail -s "SpamassassinIssue on $host exited with $?" $supportemail
fi
 
echo "Compiling"
 
/usr/bin/sa-compile
 
if [ "$?" -ne 0 ];
    then echo "SpamAssassin compile failed on $host" |mail -s "SpamassassinIssue on $host" $supportemail
fi
 
#Restart SPAMD
 
svc -d /service/qmail-smtpd
sleep 15
svc -h /service/spamd
sleep 2
svc -u /service/qmail-smtpd
if [ `svstat /service/qmail-smtpd | awk '{print $2}'` != 'up' ]; then
    echo "Issue restarting Qmail-SMTP on $host please check!" | mail -s Qmail-SMTP\ Issue\ on\ $host\ $supportemail && sleep 2 && svc -u /service/qmail-smtpd
fi
Personal tools