summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Chaintreuil <gentoo_bugs_peep@parallaxshift.com>2019-03-30 08:41:44 -0400
committerMichael Orlitzky <mjo@gentoo.org>2019-03-31 14:46:19 -0400
commit984199eccccd1fa7867c07f8a467d298eade11fa (patch)
tree5622cfe2e16e8182ce64a212d93268cf01b638d3 /mail-filter/spamassassin/files
parentsys-apps/fwupd: Revbump to fix init script with USE="elogind" (diff)
downloadgentoo-984199eccccd1fa7867c07f8a467d298eade11fa.tar.gz
gentoo-984199eccccd1fa7867c07f8a467d298eade11fa.tar.bz2
gentoo-984199eccccd1fa7867c07f8a467d298eade11fa.zip
mail-filter/spamassassin: Suppress warning in cron in some setups
Suppress warning in cron job when the script tries to restart amavisd on systemd systems where amavisd is not installed. Closes: https://bugs.gentoo.org/681872 Closes: https://github.com/gentoo/gentoo/pull/11542 Signed-off-by: Philippe Chaintreuil <gentoo_bugs_peep@parallaxshift.com> Package-Manager: Portage-2.3.62, Repoman-2.3.11 Signed-off-by: Michael Orlitzky <mjo@gentoo.org>
Diffstat (limited to 'mail-filter/spamassassin/files')
-rw-r--r--mail-filter/spamassassin/files/update-spamassassin-rules-r1.cron41
1 files changed, 41 insertions, 0 deletions
diff --git a/mail-filter/spamassassin/files/update-spamassassin-rules-r1.cron b/mail-filter/spamassassin/files/update-spamassassin-rules-r1.cron
new file mode 100644
index 00000000000..7c6990b847c
--- /dev/null
+++ b/mail-filter/spamassassin/files/update-spamassassin-rules-r1.cron
@@ -0,0 +1,41 @@
+#!/bin/bash
+#
+# Update SpamAssassin rules and reload daemons that use them.
+#
+
+# First, redirect stdout to /dev/null.
+exec 1>/dev/null
+
+# Try to update the rules.
+sa-update
+
+# Exit code 0: all new updates were installed.
+# Exit code 1: we were already up-to-date.
+# Exit code 3: some updates were installed, but some weren't.
+# Any other exit code indicates failure.
+if (( $? == 0 || $? == 3 )); then
+ # Compilation spits out its progress onto stderr.
+ sa-compile 2>/dev/null
+
+ # Do you run spamd or amavisd? Both daemons need to be reloaded
+ # in order to pick up the newly-updated rules.
+ if command -v rc-service 2>/dev/null; then
+ # OpenRC is installed. These "status" checks should succeed
+ # only when the daemon is running under OpenRC. We redirect
+ # stderr to hide the lecture that OpenRC gives you if you
+ # try this on a system running systemd.
+ rc-service spamd status 2>/dev/null && rc-service spamd reload
+ rc-service amavisd status 2>/dev/null && rc-service amavisd reload
+ fi
+
+ if command -v systemctl 2>/dev/null; then
+ # The systemctl (systemd) executable is installed, so try to
+ # use it to restart spamd and amavisd. These are safe to run
+ # if systemd is installed but not in use. The is-active
+ # check is to keep systemctl from outputting warnings if
+ # amavisd is not installed (bug #681872).
+ systemctl try-restart spamassassin
+ systemctl is-active --quiet amavisd \
+ && systemctl try-reload-or-restart amavisd
+ fi
+fi