HEX
Server: LiteSpeed
System: Linux CentOS-79-64-minimal 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: vishn3436 (5293)
PHP: 8.0.15
Disabled: NONE
Upload Files
File: //sbin/ms-update-sa
#!/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"
PIDFile=`ms-peek 'PID file' /etc/MailScanner/MailScanner.conf`

export SAUPDATE
export SACOMPILE
export SAUPDATEARGS
COMPILESUCCESS=0
LOGFILE=/tmp/ms-update-sa.$(date +%m%d%H%M%S)

if [ "x$SAUPDATE" = "x" ]; then
	# sa-update not found. exiting
	exit 0
fi


# Update SpamAssassin rules
[ -x $SAUPDATE ] || exit 0
rm -f $LOGFILE
$SAUPDATE $SAUPDATEARGS > $LOGFILE 2>&1
UPDATESUCCESS="$?"

if [ "x$SACOMPILE" = "x" ]; then
	# sa-compile not found. exiting
	exit 0
fi

if [ "x$ms_re2c" = "x" ]; then
	# re2c not found. exiting
	exit 0
fi

# 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
        if [ -f $PIDFile ]; then
            if [ -d /run/systemd/system ]; then
                systemctl -q is-active mailscanner && systemctl restart mailscanner || true
            else
                /usr/lib/MailScanner/init/ms-init restart >>$LOGFILE 2>&1 || true
            fi
        fi
fi

exit 0