Package: spamassassin
Version: 3.2.4-1
Severity: wishlist
Tags: patch
The attached patch extends cronjob to support multiple/alternate daemons.
Kind regards,
- Jonas
-- System Information:
Debian Release: lenny/sid
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.25-2-amd64 (SMP w/2 CPU cores)
Locale: LANG=da_DK.UTF-8, LC_CTYPE=da_DK.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages spamassassin depends on:
pn libarchive-tar-perl <none> (no description available)
ii libdigest-sha1-perl 2.11-2+b1 NIST SHA-1 message digest algorith
ii libhtml-parser-perl 3.56-1+b1 A collection of modules that parse
ii libnet-dns-perl 0.63-1+b1 Perform DNS queries from a Perl sc
pn libsocket6-perl <none> (no description available)
ii libsys-hostname-long-perl 1.4-2 Figure out the long (fully-qualifi
ii libwww-perl 5.812-1 WWW client/server library for Perl
ii perl 5.10.0-10 Larry Wall's Practical Extraction
ii perl-modules [libio-zlib-perl 5.10.0-10 Core Perl modules
Versions of packages spamassassin recommends:
ii gcc 4:4.3.0-8 The GNU C compiler
ii gnupg 1.4.9-2 GNU privacy guard - a free PGP rep
ii libc6-dev 2.7-12 GNU C Library: Development Librari
pn libmail-spf-perl <none> (no description available)
pn libsys-syslog-perl <none> (no description available)
ii make 3.81-5 The GNU version of the "make" util
pn re2c <none> (no description available)
pn spamc <none> (no description available)
diff -u spamassassin-3.2.4/debian/spamassassin.default
spamassassin-3.2.4/debian/spamassassin.default
--- spamassassin-3.2.4/debian/spamassassin.default
+++ spamassassin-3.2.4/debian/spamassassin.default
@@ -5,6 +5,7 @@
# There may be security risks.
# Change to one to enable spamd
+# (CRON_* and SA_UPDATE_* options below is unaffected by this setting)
ENABLED=0
# Options
@@ -31,0 +33,32 @@
+
+# Cronjob bayes token expiry
+# Set to anything but 0 to enable the cron job to automatically expire
+# old bayes tokens with the nightly cronjob
+# Dependent daemons will be fully stopped during the bayes token expiry
+# You should also disable bayes_auto_expire in /etc/spamassassin/local.cf
+CRON_BAYES_EXPIRE=0
+
+# switch (using su) to and invoke sa-update for each of these users
+# If undefined, sa-update is invoked for root
+#SA_UPDATE_USERS="amavis"
+
+# Daemons
+# Set to list of SysV daemons to be reloaded after a ruleset update.
+# If CRON_BAYES_EXPIRE enabled the daemons are instead stopped as listed
+# here and started again in reverse order
+CRON_DAEMONS="spamassassin"
+#CRON_DAEMONS="exim4 amavis"
+
+# sa-update options
+# Options passed to sa-update in cronjob
+SA_UPDATE_OPTIONS=""
+#SA_UPDATE_OPTIONS="--gpgkey D1C035168C1EBC08464946DA258CDB3ABDE9DC10
--channel saupdates.openprotect.com --channel updates.spamassassin.org"
+
+# sa-compile options
+# Options passed to sa-compile in cronjob
+SA_COMPILE_OPTIONS=""
+
+# sa-compile options
+# Options passed to sa-compile in cronjob
+SA_LEARN_OPTIONS=""
+#SA_LEARN_OPTIONS="--force-expire"
diff -u spamassassin-3.2.4/debian/spamassassin.cron.daily
spamassassin-3.2.4/debian/spamassassin.cron.daily
--- spamassassin-3.2.4/debian/spamassassin.cron.daily
+++ spamassassin-3.2.4/debian/spamassassin.cron.daily
@@ -9,11 +9,16 @@
set -e
CRON=0
+CRON_BAYES_EXPIRE=0
+CRON_DAEMONS="spamassassin"
+SA_UPDATE_USERS=""
+SA_UPDATE_OPTIONS=""
+SA_COMPILE_OPTIONS=""
+SA_LEARN_OPTIONS="--force-expire"
test -f /etc/default/spamassassin && . /etc/default/spamassassin
test -x /usr/bin/sa-update || exit 0
-test -x /etc/init.d/spamassassin || exit 0
if [ "$CRON" = "0" ] ; then
exit 0
@@ -29,15 +34,46 @@
-# Update
-sa-update || exit 0
+# Update, and catch errorlevel
+( set +e; sa-update $SA_UPDATE_OPTIONS ); sa_update_error=$?
+
+# Stop here if no update and no other tasks
+[ $sa_update_error -gt 0 ] && [ "$CRON_BAYES_EXPIRE" = "0" ] && exit 0
# Compile, if rules have previously been compiled, and it's possible
-if [ -x /usr/bin/re2c -a -x /usr/bin/sa-compile -a -d
/var/lib/spamassassin/compiled ]; then
- sa-compile > /dev/null 2>&1
+if [ $sa_update_error -eq 0 ] && [ -x /usr/bin/re2c ] && [ -x
/usr/bin/sa-compile ] && [ -d /var/lib/spamassassin/compiled ]; then
+ sa-compile $SA_COMPILE_OPTIONS > /dev/null 2>&1
fi
-# Reload
-if which invoke-rc.d >/dev/null 2>&1; then
- invoke-rc.d spamassassin reload > /dev/null 2>&1
+
+invoke_rc_d_silent() {
+ daemon="$1"
+ action="$2"
+ if which invoke-rc.d >/dev/null 2>&1; then
+ invoke-rc.d $daemon $action > /dev/null 2>&1
+ else
+ /etc/init.d/$daemon $action > /dev/null 2>&1
+ fi
+}
+
+if [ "$CRON_BAYES_EXPIRE" = "0" ]; then
+ # Reload spamassassin-dependent daemons
+ for daemon in $CRON_DAEMONS; do
+ invoke_rc_d_silent $daemon reload
+ done
else
- /etc/init.d/spamassassin reload > /dev/null 2>&1
+ # Expire old Bayes tokens and restart spamassassin-dependent daemons
+ daemons_stopped=""
+ for daemon in $CRON_DAEMONS; do
+ invoke_rc_d_silent $daemon stop
+ daemons_stopped="$daemon $daemons_stopped"
+ done
+ if [ -n "$SA_UPDATE_USERS" ]; then
+ for user in $SA_UPDATE_USERS; do
+ su -s /bin/sh -c "sa-learn $SA_LEARN_OPTIONS" $user > /dev/null 2>&1
+ done
+ else
+ sa-learn $SA_LEARN_OPTIONS > /dev/null 2>&1
+ fi
+ for daemon in $daemons_stopped; do
+ invoke_rc_d_silent $daemon start
+ done
fi