systemd plus spamd user/group support [release 3.4.0-3mamba;Thu Jan 22 2015]

This commit is contained in:
Silvan Calarco 2024-01-05 18:01:58 +01:00
parent 9c93b91f6d
commit f462ae1432
3 changed files with 61 additions and 73 deletions

View File

@ -1,57 +0,0 @@
#!/bin/sh
#
# spamassassin This script starts and stops the spamd daemon
#
# chkconfig: 2345 80 30
#
# description: spamd is a daemon process which uses SpamAssassin to check
# email messages for SPAM. It is normally called by spamc
# from a MDA.
# Source function library.
. /etc/rc.d/init.d/functions
# Source spamd configuration.
if [ -f /etc/sysconfig/spamassassin ] ; then
. /etc/sysconfig/spamassassin
else
SPAMDOPTIONS="-d -c -a -m5 -H"
fi
[ -f /usr/bin/spamd -o -f /usr/local/bin/spamd ] || exit 0
PATH=$PATH:/usr/bin:/usr/local/bin
# See how we were called.
case "$1" in
start)
# Start daemon.
echo -n "Starting spamd: "
daemon spamd $SPAMDOPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/spamassassin
;;
stop)
# Stop daemons.
echo -n "Shutting down spamd: "
killproc spamd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/spamassassin
;;
restart)
$0 stop
$0 start
;;
condrestart)
[ -e /var/lock/subsys/spamassassin ] && $0 restart
;;
status)
status spamd
;;
*)
echo "Usage: $0 {start|stop|restart|status|condrestart}"
exit 1
esac
exit 0

14
spamassassin.service Normal file
View File

@ -0,0 +1,14 @@
[Unit]
Description=Spamassassin daemon
After=syslog.target network.target
[Service]
Type=forking
PIDFile=/run/spamd.pid
ExecStart=/usr/bin/vendor_perl/spamd -d --pidfile /run/spamd.pid -c -c -x --virtual-config-dir=/var/lib/spamassassin -u spamd -g spamd
StandardOutput=syslog
StandardError=syslog
Restart=always
[Install]
WantedBy=multi-user.target

View File

@ -1,8 +1,10 @@
%define perl_major_ver %(eval `perl -V:version`; echo ${version%*.[0-9]*}.0)
%define spamd_groupid 65436
%define spamd_userid 65436
Name: spamassassin
Version: 3.4.0
Release: 2mamba
Release: 3mamba
Summary: SpamAssassin(tm) is a mail filter to identify spam
Group: System/Tools
Vendor: openmamba
@ -10,7 +12,7 @@ Distribution: openmamba
Packager: Silvan Calarco <silvan.calarco@mambasoft.it>
URL: http://spamassassin.org
Source0: http://www.apache.org/dist/spamassassin/source/Mail-SpamAssassin-%{version}.tar.bz2
Source1: spamassassin-initscript
Source1: spamassassin.service
Source2: spamassassin-conf
License: GPL
## AUTOBUILDREQ-BEGIN
@ -89,9 +91,10 @@ for dir in `find %{buildroot} -type d | grep $strid`; do
echo "%dir ${dir#%buildroot}" >> .packlist
done
install -D -m0755 spamd/redhat-rc-script.sh %{buildroot}%{_initrddir}/spamassassin
install -D %{SOURCE2} %{buildroot}%{_sysconfdir}/mail/spamassassin/local.cf
install -D -m0644 %{SOURCE1} %{buildroot}%{_unitdir}/spamassassin.service
install -p qmail/qmail-spamc %{buildroot}%{_bindir}
# dirty hack
@ -106,22 +109,47 @@ install rules/*.pre %{buildroot}%{_sysconfdir}/mail/spamassassin/
%clean
[ "%{buildroot}" != / ] && rm -rf %{buildroot}
%post
%pre
if [ $1 -ge 1 ]; then
chkconfig spamassassin on
systemctl daemon-reload
systemctl start spamassassin
sa-update
/usr/sbin/groupadd spamd -g %{spamd_groupid} 2>/dev/null
/usr/sbin/useradd -u %{spamd_userid} -c 'Spamassassin user' -d /var/lib/spamassassin -g spamd \
-s /bin/false spamd 2>/dev/null
fi
exit 0
:
%post
%systemd_post spamassassin
if [ $1 -ge 1 ]; then
sa-update &>/dev/null
# sysv -> systemd upgrade
if [ -L /etc/rc.d/rc5.d/S78spamassassin -o -L /etc/rc.d/rc3.d/S78spamassassin ]; then
systemctl -q enable postfix
systemctl -q restart postfix
fi
fi
if [ $1 -eq 1 ]; then
systemctl -q enable spamassassin
systemctl -q start spamassassin
fi
:
%preun
%systemd_preun spamassassin
if [ $1 -eq 0 ]; then
/usr/sbin/userdel spamd 2>/dev/null
/usr/sbin/groupdel spamd 2>/dev/null
fi
:
%postun
# upgrade
if [ $1 -eq 1 ]; then
chkconfig spamassassin
[ $? -eq 0 ] && chkconfig spamassassin off
fi
exit 0
%systemd_postun_with_restart spamassassin
:
%posttrans
# clean old sysv broken links
find /etc/rc[0-6].d/ -type l -xtype l -exec rm -f {} \;
:
%files -f .packlist
%defattr(-,root,root)
@ -136,9 +164,12 @@ exit 0
%{_bindir}/qmail-spamc
%dir %{_datadir}/spamassassin
%{_datadir}/spamassassin/*
%{_initrddir}/spamassassin
%{_unitdir}/spamassassin.service
%changelog
* Thu Jan 22 2015 Silvan Calarco <silvan.calarco@mambasoft.it> 3.4.0-3mamba
- systemd plus spamd user/group support
* Thu Jul 24 2014 Silvan Calarco <silvan.calarco@mambasoft.it> 3.4.0-2mamba
- initscript: don't check obsoleted /etc/sysconfig/network