Switch to systemd timer unit from cron for rules updates. Fixes bug #1064537

This commit is contained in:
Kevin Fenzi 2015-04-03 11:34:14 -06:00
parent ec777e5ac4
commit 569fc65779
4 changed files with 63 additions and 3 deletions

28
sa-update.service Normal file
View File

@ -0,0 +1,28 @@
### Spamassassin Rules Updates ###
#
# http://wiki.apache.org/spamassassin/RuleUpdates
#
# sa-update automatically updates your rules once per day if a spam daemon like
# spamd or amavisd are running.
[Unit]
Description=Spamassassin Rules Update
Documentation=man:sa-update(1)
[Service]
# Note that the opposite of "yes" is the empty string, NOT "no"
# Options for the actual sa-update command
# These are added to the channel configuration from
# /etc/mail/spamassassin/channel.d/*.conf
Environment=OPTIONS=-v
# Debug script - send mail even if no update available
#Environment=DEBUG=yes
# Send mail when updates successfully processed
# Default: send mail only on error
#Environment=NOTIFY_UPD=yes
ExecStart=/usr/share/spamassassin/sa-update.cron
SuccessExitStatus=1

16
sa-update.timer Normal file
View File

@ -0,0 +1,16 @@
### Spamassassin Rules Updates ###
#
# http://wiki.apache.org/spamassassin/RuleUpdates
#
# sa-update automatically updates your rules once per day if a spam daemon like
# spamd or amavisd are running.
[Unit]
Description=Spamassassin Rules Update timer
Documentation=man:sa-update(1)
[Timer]
OnCalendar=daily
[Install]
WantedBy=spamassassin.service

View File

@ -1,6 +1,7 @@
[Unit]
Description=Spamassassin daemon
After=syslog.target network.target
Wants=sa-update.timer
[Service]
EnvironmentFile=-/etc/sysconfig/spamassassin

View File

@ -63,7 +63,7 @@ Summary: Spam filter for email which can be invoked from mail delivery agents
Name: spamassassin
Version: 3.4.0
#Release: 0.8.%{prerev}%{?dist}
Release: 13%{?dist}
Release: 14%{?dist}
License: ASL 2.0
Group: Applications/Internet
URL: http://spamassassin.apache.org/
@ -87,6 +87,8 @@ Source13: README.RHEL.Fedora
Source14: spamassassin.service
%endif
Source15: spamassassin.sysconfig.el
Source16: sa-update.service
Source17: sa-update.timer
# Patches 0-99 are RH specific
# https://bugzilla.redhat.com/show_bug.cgi?id=1055593
@ -207,7 +209,6 @@ install -m 0755 spamd/redhat-rc-script.sh %buildroot/%{_initrddir}/spamassassin
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/mail/spamassassin
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/cron.d
install -m 0644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/mail/spamassassin/local.cf
%if %{use_systemd}
install -m644 %{SOURCE5} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/spamassassin
@ -221,13 +222,19 @@ install -m 0644 %{SOURCE4} %buildroot/etc/mail/spamassassin
install -m 0755 %{SOURCE10} %buildroot/etc/mail/spamassassin
install -m 0644 %{SOURCE6} %buildroot/etc/logrotate.d/sa-update
%if %{use_systemd} == 0
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/cron.d
install -m 0644 %{SOURCE7} %buildroot/etc/cron.d/sa-update
%endif
install -m 0644 %{SOURCE9} %buildroot%{_sysconfdir}/sysconfig/sa-update
# installed mode 744 as non root users can't run it, but can read it.
install -m 0744 %{SOURCE8} %buildroot%{_datadir}/spamassassin/sa-update.cron
%if %{use_systemd}
mkdir -p %buildroot%{_unitdir}
install -m 0644 %{SOURCE14} %buildroot%{_unitdir}/spamassassin.service
install -m 0644 %{SOURCE16} %buildroot%{_unitdir}/sa-update.service
install -m 0644 %{SOURCE17} %buildroot%{_unitdir}/sa-update.timer
%endif
[ -x /usr/lib/rpm/brp-compress ] && /usr/lib/rpm/brp-compress
@ -272,18 +279,20 @@ install -m 0644 %{SOURCE13} $RPM_BUILD_DIR/Mail-SpamAssassin-%{version}/
%doc README.RHEL.Fedora
%if %{use_systemd} == 0
%{_initrddir}/spamassassin
%{_sysconfdir}/cron.d/sa-update
%endif
%dir %{_sysconfdir}/mail
%config(noreplace) %{_sysconfdir}/mail/spamassassin
%config(noreplace) %{_sysconfdir}/sysconfig/spamassassin
%config(noreplace) %{_sysconfdir}/sysconfig/sa-update
%{_sysconfdir}/cron.d/sa-update
%dir %{_datadir}/spamassassin
%dir %{_localstatedir}/run/spamassassin
%dir %{_localstatedir}/lib/spamassassin
%config(noreplace) %{_sysconfdir}/logrotate.d/sa-update
%if %{use_systemd}
%{_unitdir}/spamassassin.service
%{_unitdir}/sa-update.service
%{_unitdir}/sa-update.timer
%endif
%clean
@ -296,6 +305,7 @@ rm -rf $RPM_BUILD_ROOT
%if %{use_systemd}
%systemd_post spamassassin.service
%systemd_post sa-update.timer
%endif
# -a and --auto-whitelist options were removed from 3.0.0
@ -325,6 +335,7 @@ exit 0
%if %{use_systemd}
%systemd_postun spamassassin.service
%systemd_postun sa-update.timer
%endif
%preun
@ -338,6 +349,7 @@ exit 0
%if %{use_systemd}
%systemd_preun spamassassin.service
%systemd_preun sa-update.timer
%endif
%if %{use_systemd}
@ -350,6 +362,9 @@ exit 0
%endif
%changelog
* Fri Apr 03 2015 Kevin Fenzi <kevin@scrye.com> 3.4.0-14
- Switch to systemd timer unit from cron for rules updates. Fixes bug #1064537
* Fri Apr 03 2015 Kevin Fenzi <kevin@scrye.com> 3.4.0-13
- Remove last parts of portreserve. Fixes bug #1175798
- Fix typo in Razor2 plugin. Fixes bug #1208776