Commit new service file for systemd
This commit is contained in:
parent
15fb484368
commit
a458ea91d8
13
spamassassin.service
Normal file
13
spamassassin.service
Normal file
@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=Spamassassin daemon
|
||||
|
||||
[Service]
|
||||
EnvironmentFile=/etc/sysconfig/spamassassin
|
||||
ExecStartPre=-/sbin/portrelease spamd
|
||||
ExecStart=/usr/bin/spamd ${SPAMDOPTIONS}
|
||||
Restart=always
|
||||
StandardOutput=syslog
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
@ -24,6 +24,7 @@
|
||||
%define perl_devel 0
|
||||
%define dkim_deps 0
|
||||
%define require_encode_detect 0
|
||||
%define use_systemd 0
|
||||
|
||||
# SSL and IPv6 (FC6+, RHEL5+)
|
||||
%if 0%{?fedora} > 5
|
||||
@ -51,6 +52,10 @@ Requires: portreserve
|
||||
%define dkim_deps 1
|
||||
%endif
|
||||
|
||||
%if 0%{?fedora} >= 15
|
||||
%define use_systemd 1
|
||||
%endif
|
||||
|
||||
%define real_name Mail-SpamAssassin
|
||||
%{!?perl_vendorlib: %define perl_vendorlib %(eval "`%{__perl} -V:installvendorlib`"; echo $installvendorlib)}
|
||||
|
||||
@ -61,7 +66,7 @@ Summary: Spam filter for email which can be invoked from mail delivery agents
|
||||
Name: spamassassin
|
||||
Version: 3.3.2
|
||||
#Release: 0.8.%{prerev}%{?dist}
|
||||
Release: 1%{?dist}
|
||||
Release: 2%{?dist}
|
||||
License: ASL 2.0
|
||||
Group: Applications/Internet
|
||||
URL: http://spamassassin.apache.org/
|
||||
@ -81,6 +86,9 @@ Source10: spamassassin-helper.sh
|
||||
Source11: spamassassin-official.conf
|
||||
Source12: sought.conf
|
||||
Source13: README.RHEL.Fedora
|
||||
%if %{use_systemd}
|
||||
Source14: spamassassin.service
|
||||
%endif
|
||||
# Patches 0-99 are RH specific
|
||||
# none yet
|
||||
# Patches 100+ are SVN backports (DO NOT REUSE!)
|
||||
@ -96,6 +104,9 @@ BuildRequires: perl(Time::HiRes)
|
||||
BuildRequires: perl(HTML::Parser)
|
||||
BuildRequires: perl(NetAddr::IP)
|
||||
BuildRequires: openssl-devel
|
||||
%if %{use_systemd}
|
||||
BuildRequires: systemd-units
|
||||
%endif
|
||||
|
||||
Requires: perl(HTTP::Date)
|
||||
Requires: perl(LWP::UserAgent)
|
||||
@ -129,7 +140,12 @@ BuildRequires: perl-devel
|
||||
Requires: perl(Mail::DKIM)
|
||||
%endif
|
||||
|
||||
|
||||
%if %{use_systemd}
|
||||
Requires(post): systemd-units
|
||||
Requires(post): systemd-sysv
|
||||
Requires(preun): systemd-units
|
||||
Requires(postun): systemd-units
|
||||
%endif
|
||||
|
||||
Obsoletes: perl-Mail-SpamAssassin
|
||||
|
||||
@ -191,6 +207,10 @@ install -m 0644 %{SOURCE7} %buildroot/etc/cron.d/sa-update
|
||||
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
|
||||
%endif
|
||||
|
||||
[ -x /usr/lib/rpm/brp-compress ] && /usr/lib/rpm/brp-compress
|
||||
|
||||
@ -245,12 +265,24 @@ install -m 0644 %{SOURCE13} $RPM_BUILD_DIR/Mail-SpamAssassin-%{version}/
|
||||
%dir %{_localstatedir}/lib/spamassassin
|
||||
%config(noreplace) %{_sysconfdir}/logrotate.d/sa-update
|
||||
%config(noreplace) %{_sysconfdir}/portreserve/spamd
|
||||
%if %{use_systemd}
|
||||
%{_unitdir}/spamassassin.service
|
||||
%endif
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%post
|
||||
%if %{use_systemd} == 0
|
||||
/sbin/chkconfig --add spamassassin
|
||||
%endif
|
||||
|
||||
%if %{use_systemd}
|
||||
if [ $1 -eq 1 ] ; then
|
||||
# Initial installation
|
||||
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
|
||||
fi
|
||||
%endif
|
||||
|
||||
# -a and --auto-whitelist options were removed from 3.0.0
|
||||
# prevent service startup failure
|
||||
@ -270,17 +302,46 @@ if [ -f /etc/mail/spamassassin.cf ]; then
|
||||
fi
|
||||
|
||||
%postun
|
||||
%if %{use_systemd} == 0
|
||||
if [ "$1" -ge "1" ]; then
|
||||
/sbin/service spamassassin condrestart > /dev/null 2>&1
|
||||
fi
|
||||
exit 0
|
||||
%endif
|
||||
|
||||
%if %{use_systemd}
|
||||
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
|
||||
if [ $1 -ge 1 ] ; then
|
||||
# Package upgrade, not uninstall
|
||||
/bin/systemctl try-restart spamassassin.service >/dev/null 2>&1 || :
|
||||
fi
|
||||
%endif
|
||||
|
||||
%preun
|
||||
%if %{use_systemd} == 0
|
||||
if [ $1 = 0 ] ; then
|
||||
/sbin/service spamassassin stop >/dev/null 2>&1
|
||||
/sbin/chkconfig --del spamassassin
|
||||
fi
|
||||
exit 0
|
||||
%endif
|
||||
|
||||
%if %{use_systemd}
|
||||
if [ $1 -eq 0 ] ; then
|
||||
# Package removal, not upgrade
|
||||
/bin/systemctl --no-reload disable spamassassin.service > /dev/null 2>&1 || :
|
||||
/bin/systemctl stop spamassassin.service > /dev/null 2>&1 || :
|
||||
fi
|
||||
%endif
|
||||
|
||||
%if %{use_systemd}
|
||||
%triggerun -- spamassassin < 3.3.2-2
|
||||
%{_bindir}/systemd-sysv-convert --save spamassassin >/dev/null 2>&1 ||:
|
||||
|
||||
# Run these because the SysV package being removed won't do them
|
||||
/sbin/chkconfig --del spamassassin >/dev/null 2>&1 || :
|
||||
/bin/systemctl try-restart spamassassin.service >/dev/null 2>&1 || :
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Mon Jun 6 2011 Warren Togami <warren@togami.com> - 3.3.2-1
|
||||
|
Loading…
Reference in New Issue
Block a user