The patch works but it's confusing.
File /etc/default/spamassassin mentions that the ENABLED setting is only
used for a sysvinit machine. If you enable the service on a systemd
machine with "systemctl enable spamassassin.service" and leave
ENABLED=0, the cron job would not reload the service with this patch.
I guess we should simply check if spamd is running before trying to
reload it? Is it ok to use pidof?
--- /a/spamassassin 2015-04-16 14:09:52.363384562 +0200
+++ /b/spamassassin 2015-04-16 14:12:16.471389193 +0200
@@ -47,11 +47,13 @@
# Tell a running spamd to reload its configs and rules.
reload() {
- # Reload
- if which invoke-rc.d >/dev/null 2>&1; then
- invoke-rc.d spamassassin reload > /dev/null
- else
- /etc/init.d/spamassassin reload > /dev/null
+ # Reload only if spamd is running.
+ if pidof spamd >/dev/null; then
+ if which invoke-rc.d >/dev/null 2>&1; then
+ invoke-rc.d spamassassin reload > /dev/null
+ else
+ /etc/init.d/spamassassin reload > /dev/null
+ fi
fi
if [ -d /etc/spamassassin/sa-update-hooks.d ]; then
run-parts --lsbsysinit /etc/spamassassin/sa-update-hooks.d