ports/127242: Add nightly periodic(8) script that uses sa-update

Jeremy Chadwick koitsu at FreeBSD.org
Tue Sep 9 10:30:02 UTC 2008


>Number:         127242
>Category:       ports
>Synopsis:       Add nightly periodic(8) script that uses sa-update
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Sep 09 10:30:01 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Jeremy Chadwick
>Release:        FreeBSD 7.1-PRERELEASE amd64
>Organization:
>Environment:
System: FreeBSD icarus.home.lan 7.1-PRERELEASE FreeBSD 7.1-PRERELEASE #0: Tue Sep 2 00:14:39 PDT 2008 root at icarus.home.lan:/usr/obj/usr/src/sys/PDSMI_PLUS_amd64 amd64
>Description:
	It would be convenient if we have a periodic(8) script that ran
	sa-update nightly, allowing new rules to be downloaded automatically.
>How-To-Repeat:
	n/a
>Fix:
	Below is the script.  Note that the hard-coded /usr/local paths will
	need to be changed to %%WHATEVER%% and expanded.  (I'm being somehwat
	lazy tonight, otherwise I'd include a full diff/patch for the port
	Makefile and related stuffs)

	periodic flags used are fairly self-descriptive.  :-)



#!/bin/sh -f
#
# $FreeBSD$
#
# periodic(8) script that runs sa-update on a nightly basis, updating
# SpamAssassin rules if needed.  Relies on sa-update command.
#
# Contributed by: Jeremy Chadwick <koitsu at FreeBSD.org>
#
# Define these variables in either /etc/periodic.conf or
# /etc/periodic.conf.local to override the defaults.
#
# Examples:
#
# saupdate_enable="YES"		# run sa-update(1) daily
# saupdate_flags="--nogpg"	# flags passed to sa-update, e.g. disable GPG support
# saupdate_restart_spamd="YES"	# Restart sa-spamd when new rules are found


# If there is a global system configuration file, suck it in.
#
if [ -r /etc/defaults/periodic.conf ]
then
    . /etc/defaults/periodic.conf
    source_periodic_confs
fi

: ${saupdate_enable="NO"}
: ${saupdate_flags=""}
: ${saupdate_restart_spamd="YES"}

rc=0
case "$saupdate_enable" in
    [Yy][Ee][Ss])
	echo
	echo "Running sa-update:"
	echo

	/usr/local/bin/sa-update ${saupdate_flags} || rc=$?

	if [ $rc -eq 0 ]; then
		echo "Downloaded and installed new rules."
		echo
		case "$saupdate_restart_spamd" in
		    [Yy][Ee][Ss])
			echo "Restarting sa-spamd:"
			echo
			/usr/local/etc/rc.d/sa-spamd restart
			;;
		    *)  ;;
		esac
	elif [ $rc -eq 1 ]; then
		echo "No new rules available."
		rc=0
	else
		echo "sa-update failed with exit code $rc.  Please refer to the sa-update(1)"
		echo "man page for details."
	fi
	;;
    *)  rc=0 ;;
esac

exit $rc
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list