Sophie

Sophie

distrib > Mandriva > 2009.0 > i586 > by-pkgid > c7cb955762a131fb8719780cc55cac4c > files > 4

spamassassin-3.2.5-5mdv2009.0.src.rpm

#!/bin/sh

# A simple script to update the SA rules. There is very little error
# checking here. It is implied your machine has network, dns resolving
# and all that.
# 
# Oden Eriksson <oeriksson@mandriva.com>

# Source spamd configuration.
. /etc/sysconfig/spamd

if [ "${USE_SA_UPDATE}" == "1" ]; then

    RETVAL1="0"
    RETVAL2="0"
    RETVAL3="0"
    LOCKFILE="/tmp/sa-update.lock"

    # yonder some
    if [ -f ${LOCKFILE} ]; then
	echo "ERROR: The ${LOCKFILE} file was found indicating an error. Maybe sa-update is still running..."
	exit 1
    fi

    # make the lockfile
    touch ${LOCKFILE}

    # update the rules
    /usr/bin/sa-update ${SA_UPDATE_OPTIONS}
    RETVAL1="$?"

    if [ $RETVAL1 -eq "0" ]; then

	    # compile the rules
	    if [ "${USE_SA_COMPILED_RULES}" == "1" ]; then
		if ! [ -x /usr/bin/re2c ]; then
		    echo "ERROR: /usr/bin/re2c is missing, spamd may not be working properly..."
    		    exit 1
		fi		    
		/usr/bin/sa-compile ${SA_COMPILE_OPTIONS}
		RETVAL2="$?"
		if [ $RETVAL2 -gt "0" ]; then
		    echo "ERROR: There were problems compiling the rules, spamd may not be working properly..."
    		    exit 1
    		fi
	    fi

	# verify it's working
	spamassassin --lint ${SA_LINT_OPTIONS}
	RETVAL3="$?"
	if [ $RETVAL3 -gt "0" ]; then
	    echo "ERROR: There were problems with the configuration, spamd may not be working properly..."
        fi

	# restart spamd
        /etc/rc.d/init.d/spamd condrestart

	# verify it's running
	SA_PID=`pidof spamd`
	if [ -z "$SA_PID" ]; then
	    echo "ERROR: spamd did not start..."
	    rm -f ${LOCKFILE}
	    exit 1
	fi

	# hopefully everything's ok
	rm -f ${LOCKFILE}
        exit 0
    fi

    # do nothing
    if [ $RETVAL1 -eq "1" ]; then
        echo "No new rules was downloaded..."
	rm -f ${LOCKFILE}
        exit 0
    fi

    # barf some
    if [ $RETVAL1 -gt "4" ]; then
        echo "ERROR: There were problems with the updated rules, spamd was not restarted..."
	rm -f ${LOCKFILE}
        exit 1
    fi

fi