v5/common/usr/sbin/ms-update-sa
Jerry.Benton a4716cd68c update
none
2016-05-01 18:43:24 -04:00

43 lines
1.1 KiB
Bash

#!/bin/sh
# created: Jerry Benton <mailscanner@mailborder.com>
# 28 APR 2016
SAUPDATE=`which sa-update`
SACOMPILE=`which sa-compile`
ms_re2c=`which re2c`
SAUPDATEARGS="--refreshmirrors"
export SAUPDATE
export SACOMPILE
export SAUPDATEARGS
COMPILESUCCESS=0
LOGFILE=/tmp/ms-update-sa.$(date +%m%d%H%M%S)
# Update SpamAssassin rules
[ -x $SAUPDATE ] || exit 0
rm -f $LOGFILE
$SAUPDATE $SAUPDATEARGS > $LOGFILE 2>&1
UPDATESUCCESS="$?"
# If we have sa-compile and they are using the Rule2XSBody plugin then compile
grep -q '^loadplugin.*Rule2XSBody' /etc/mail/spamassassin/*pre 2>/dev/null
RETVAL="$?"
if [ -x $SACOMPILE -a -x $ms_re2c -a $RETVAL -eq 0 ] ; then
$SACOMPILE >>$LOGFILE 2>&1
COMPILESUCCESS=$?
logger -i -p mail.notice "ms-update-sa: compiled spamassassin rules"
else
logger -i -p mail.notice "ms-update-sa: skipped spamassassin sa-compile"
COMPILESUCCESS=1
fi
# Only delete the logfile if the update succeeded
if [ $UPDATESUCCESS = 0 -a $COMPILESUCCESS = 0 -o $UPDATESUCCESS = 1 ]; then
logger -i -p mail.notice "ms-update-sa: spamassassin signatures updated"
rm -f $LOGFILE
. /var/lib/MailScanner/init/ms-init reload >>$LOGFILE 2>&1
fi
exit 0