ports/142465: [new port] mail/sa-utils -- periodic script for maintaining spamAssassin rulesets.
Matthew Seaman
m.seaman at infracaninophile.co.uk
Fri Jan 8 10:20:01 UTC 2010
>Number: 142465
>Category: ports
>Synopsis: [new port] mail/sa-utils -- periodic script for maintaining spamAssassin rulesets.
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Fri Jan 08 10:20:00 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator: Matthew Seaman
>Release: FreeBSD 8.0-STABLE i386
>Organization:
Infracaninophile
>Environment:
System: FreeBSD happy-idiot-talk.infracaninophile.co.uk 8.0-STABLE FreeBSD 8.0-STABLE #16: Mon Jan 4 17:33:45 GMT 2010 root at happy-idiot-talk.infracaninophile.co.uk:/usr/obj/usr/src/sys/HAPPY-IDIOT-TALK i386
>Description:
Following the recent fun and games with the FH_DATE_PAST_20XX SpamAssassin
rule and discussions on the freebsd-questions at ... list, I have out together
a small periodic script to do a daily check for SpamAssassin rule updates.
It should be sufficiently configurable to suit the needs of most users.
Thanks to:
Jeremy Chadwick -- for the original script in ports/127242 that I
have folded, spindled and mutilated into this
RW and particularly Matt Emmerton -- for testing and coming up with
some useful improvements.
>How-To-Repeat:
>Fix:
--- sa-utils.shar begins here ---
# This is a shell archive. Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file". Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
# sa-utils
# sa-utils/files
# sa-utils/files/sa-utils.in
# sa-utils/Makefile
# sa-utils/pkg-descr
#
echo c - sa-utils
mkdir -p sa-utils > /dev/null 2>&1
echo c - sa-utils/files
mkdir -p sa-utils/files > /dev/null 2>&1
echo x - sa-utils/files/sa-utils.in
sed 's/^X//' >sa-utils/files/sa-utils.in << '6dbe6f7ecb1b2779ea53fa72047973fc'
X#!/bin/sh
X#
X# $FreeBSD$
X#
X# periodic(8) script that runs sa-update on a nightly basis, updating
X# SpamAssassin rules if needed. Relies on sa-update command.
X#
X# Originally contributed by: Jeremy Chadwick <koitsu at FreeBSD.org>
X# Extended and enhanced by: Matthew Seaman <m.seaman at infracaninophile.co.uk>
X#
X# Define these variables in either /etc/periodic.conf or
X# /etc/periodic.conf.local to override the defaults.
X#
X# Configuration Settings (with default values):
X#
X# daily_sa_enable="YES"
X# run sa-update(1) daily. We assume you want this since
X# you've installed the port.
X#
X# daily_sa_quiet="NO"
X# discard output from sa-update, sa-compile, sa-spamd if set
X# to YES. sa-compile in particular is quite verbose, so
X# setting this to YES can avoid some occasional excess
X# verbiage in your daily e-mails.
X#
X# daily_sa_update_flags=""
X# flags to pass to sa-update. eg. to download additional
X# updates from saupdates.example.com, signed with a GPG key
X# with fingerprint 0xCAFEBABE which you have previously
X# downloaded and installed into the sa-update keyring:
X# daily_sa_update_flags="--gpgkey CAFEBABE \
X# --channel saupdates.example.com \
X# --channel updates.spamassassin.org"
X#
X# daily_sa_compile="YES"
X# run sa-compile to create a compiled form of the filter
X# rules when new rules are found. Note: this can be time
X# consuming and CPU intensive.
X#
X# daily_sa_compile_flags=""
X# flags to pass to sa-compile. eg to enable debug output
X# daily_sa_compile_flags="-D"
X#
X# daily_sa_compile_nice="YES"
X# run sa-compile via nice(1) to minimize its impact on the
X# the system.
X#
X# daily_sa_compile_nice_flags=""
X# flags to pass to nice(1). eg to use a priority increment
X# different than the default.
X# daily_sa_compile_nice_flags="-n 16"
X#
X# daily_sa_restart_spamd="YES"
X# automatically restart sa-spamd when new rules are found.
X# If daily_sa_compile is enabled, only restart if new rules
X# are found and compilation succeeds
X
X# If there is a global system configuration file, suck it in.
X#
Xif [ -r /etc/defaults/periodic.conf ]
Xthen
X . /etc/defaults/periodic.conf
X source_periodic_confs
Xfi
X
X: ${daily_sa_enable="YES"}
X: ${daily_sa_quiet="NO"}
X: ${daily_sa_update_flags=""}
X: ${daily_sa_compile="YES"}
X: ${daily_sa_compile_flags=""}
X: ${daily_sa_compile_nice="YES"}
X: ${daily_sa_compile_nice_flags=""}
X: ${daily_sa_restart_spamd="YES"}
X
XPATH=/bin:/sbin:/usr/bin:/usr/sbin:%%LOCALBASE%%/bin:%%LOCALBASE%%/sbin
Xexport PATH
X
Xupdate_rules() {
X echo
X echo "Checking for new SpamAssassin rules:"
X
X eval sa-update ${daily_sa_update_flags} ${_output} || rc=$?
X
X return $rc
X}
X
X# If enabled, run sa-compile to compile the updated rulesets. This
X# can require significant time and CPU.
Xcompile_rules() {
X case "$daily_sa_compile_nice" in
X [Yy][Ee][Ss])
X _nice="nice $daily_sa_compile_nice_flags"
X ;;
X *)
X _nice=
X ;;
X esac
X
X case "$daily_sa_compile" in
X [Yy][Ee][Ss])
X echo " Compiling new rules"
X eval ${_nice} sa-compile ${daily_sa_compile_flags} ${_output} || rc=$?
X
X if [ $rc -ne 0 ] ; then
X echo "Error: sa-compile exited with code $rc"
X rc=3
X fi
X ;;
X
X *) ;; # Do nothing
X esac
X
X return $rc
X}
X
X# If update_rules() downloads new rules, and if compile_rules succeeds
X# or is not enabled, then restart the spamd daemon.
Xrestart_spamd() {
X case "$daily_sa_restart_spamd" in
X [Yy][Ee][Ss])
X echo " Restarting sa-spamd"
X eval %%LOCALBASE%%/etc/rc.d/sa-spamd restart ${_output} || rc=$?
X
X if [ $rc -ne 0 ] ; then
X echo "Error: failed to restart sa-spamd"
X rc=3
X fi
X ;;
X
X *) ;; # Do nothing
X esac
X
X return $rc
X}
X
Xrc=0
Xcase "$daily_sa_enable" in
X [Yy][Ee][Ss])
X case ${daily_sa_quiet} in
X [Yy][Ee][Ss])
X _output='>/dev/null 2>&1'
X ;;
X *)
X _output=
X ;;
X esac
X
X update_rules || rc=$?
X case ${rc} in
X 0)
X echo "Successfully downloaded updated rules"
X compile_rules && \
X restart_spamd
X ;;
X 1)
X echo "No new rules available."
X rc=0
X ;;
X *)
X echo "Error: sa-update exited with code ${rc}"
X rc=3
X ;;
X esac
X ;;
X
X *) ;; # Nothing to do
Xesac
X
Xexit $rc
6dbe6f7ecb1b2779ea53fa72047973fc
echo x - sa-utils/Makefile
sed 's/^X//' >sa-utils/Makefile << 'b7f1afd1a38c0e689c15acf6dbbc6585'
X# New ports collection makefile for: sa-utils
X# Date created: 3 January 2010
X# Whom: Matthew Seaman <m.seaman at infracaninophile.co.uk>
X#
X# $FreeBSD$
X#
X# Port is self-contained in the files directory.
X
XPORTNAME= sa-utils
XPORTVERSION= 0.02
XCATEGORIES= mail
XMASTER_SITES= # none
XDISTFILES= # none
X
XMAINTAINER= m.seaman at infracaninophile.co.uk
XCOMMENT= SpamAssassin nightly periodic maintenance
X
XRUN_DEPENDS= sa-update:${PORTSDIR}/mail/p5-Mail-SpamAssassin \
X re2c:${PORTSDIR}/devel/re2c
X
XNO_BUILD= yes
XSUB_FILES= sa-utils
X
XPERIODIC_DAILY= etc/periodic/daily
X
XPLIST_FILES= ${PERIODIC_DAILY}/sa-utils
XPLIST_DIRS= ${PERIODIC_DAILY} ${PERIODIC_DAILY:H}
X
Xdo-install:
X ${MKDIR} ${PREFIX}/${PERIODIC_DAILY}
X ${INSTALL_SCRIPT} ${WRKDIR}/sa-utils \
X ${PREFIX}/${PERIODIC_DAILY}/sa-utils
X
X.include <bsd.port.mk>
b7f1afd1a38c0e689c15acf6dbbc6585
echo x - sa-utils/pkg-descr
sed 's/^X//' >sa-utils/pkg-descr << '995f497607dcf2517aee164ea90f3745'
XRoutine maintenance script for p5-Mail-SpamAssassin to run as a daily
Xperiodic job.
X
X * Check for updates to sa rules and download
X * Optionally use sa-compile to build a compiled set of rules
X * Optionally restart spamd whenever new rules are downloaded
X * Manage multiple update channels and GPG keys
995f497607dcf2517aee164ea90f3745
exit
--- sa-utils.shar ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list