[postgrey] Migrate to systemd.
Jon Ciesla
limb at fedoraproject.org
Tue Mar 20 13:34:30 UTC 2012
commit 497f8ed26b3cfb05a49897a622d98a6889193b24
Author: Jon Ciesla <limburgher at gmail.com>
Date: Tue Mar 20 08:33:46 2012 -0500
Migrate to systemd.
postgrey.service | 23 +++++++++++++++++++
postgrey.spec | 63 ++++++++++++++++++++++++++++++++++++++++-----------
postgrey.sysconfig | 1 +
3 files changed, 73 insertions(+), 14 deletions(-)
---
diff --git a/postgrey.service b/postgrey.service
new file mode 100644
index 0000000..4cb5ede
--- /dev/null
+++ b/postgrey.service
@@ -0,0 +1,23 @@
+[Unit]
+Description=Postfix Greylisting Service
+Before=postfix.service
+
+[Service]
+Type=forking
+
+EnvironmentFile=-/etc/sysconfig/postgrey
+ExecStartPre=-/bin/rm -f /var/run/postgrey.pid
+
+PIDFile=/var/run/postgrey.pid
+
+ExecStart=/usr/sbin/postgrey \
+ --unix=/var/spool/postfix/postgrey/socket \
+ --pidfile=/var/run/postgrey.pid \
+ --daemonize \
+ $POSTGREY_OPTS
+
+Restart=always
+RestartSec=1
+
+[Install]
+WantedBy=multi-user.target
diff --git a/postgrey.spec b/postgrey.spec
index f20f61f..433c217 100644
--- a/postgrey.spec
+++ b/postgrey.spec
@@ -3,23 +3,27 @@
Summary: Postfix Greylisting Policy Server
Name: postgrey
Version: 1.34
-Release: 2%{?dist}
+Release: 3%{?dist}
# File headers only state "GNU GPL", but the LICENSE sections state v2 and "any
# later version"
License: GPLv2+
Group: System Environment/Daemons
URL: http://postgrey.schweikert.ch/
Source0: http://postgrey.schweikert.ch/pub/postgrey-%{version}.tar.gz
-Source1: postgrey.init
+Source1: postgrey.service
Source2: README-rpm
+Source3: postgrey.sysconfig
Patch0: postgrey-1.28-group.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
# We require postfix for its directories and gid
Requires: postfix
Requires(pre): /usr/sbin/useradd
-Requires(post): /sbin/chkconfig
-Requires(preun): /sbin/service, /sbin/chkconfig
-Requires(postun): /sbin/service
+#Requires(post): /sbin/chkconfig
+#Requires(preun): /sbin/service, /sbin/chkconfig
+#Requires(postun): /sbin/service
+Requires(post): systemd-units
+Requires(preun): systemd-units
+Requires(postun): systemd-units
BuildArch: noarch
%description
@@ -63,8 +67,12 @@ echo "# Clients that should not be greylisted. See postgrey(8)." \
%{__mkdir_p} %{buildroot}%{_var}/spool/postfix/postgrey
# Init script
-%{__install} -D -p -m 0755 %{SOURCE1} \
- %{buildroot}%{_sysconfdir}/rc.d/init.d/postgrey
+%{__install} -D -p -m 0644 %{SOURCE1} \
+ %{buildroot}%{_unitdir}/postgrey.service
+
+# Sysconfig
+%{__install} -D -p -m 0644 %{SOURCE3} \
+ %{buildroot}%{_sysconfdir}/sysconfig/postgrey
# Man page
%{__install} -D -p -m 0644 postgrey.8 \
@@ -84,24 +92,48 @@ echo "# Clients that should not be greylisted. See postgrey(8)." \
-M -r postgrey &>/dev/null || :
%post
-/sbin/chkconfig --add postgrey
+#/sbin/chkconfig --add postgrey
+if [ $1 -eq 1 ] ; then
+ # Initial installation
+ /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+fi
%preun
-if [ $1 -eq 0 ]; then
- /sbin/service postgrey stop &>/dev/null || :
- /sbin/chkconfig --del postgrey
+#if [ $1 -eq 0 ]; then
+# /sbin/service postgrey stop &>/dev/null || :
+# /sbin/chkconfig --del postgrey
+#fi
+if [ $1 -eq 0 ] ; then
+ # Package removal, not upgrade
+ /bin/systemctl --no-reload disable postgrey.service > /dev/null 2>&1 || :
+ /bin/systemctl stop postgrey.service > /dev/null 2>&1 || :
fi
%postun
-if [ $1 -ge 1 ]; then
- /sbin/service postgrey condrestart &>/dev/null || :
+#if [ $1 -ge 1 ]; then
+# /sbin/service postgrey condrestart &>/dev/null || :
+#fi
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+if [ $1 -ge 1 ] ; then
+ # Package upgrade, not uninstall
+ /bin/systemctl try-restart postgrey.service >/dev/null 2>&1 || :
fi
+%triggerun -- postgrey < 1.34-3
+# Save the current service runlevel info
+# User must manually run systemd-sysv-convert --apply postgrey
+# to migrate them to systemd targets
+/usr/bin/systemd-sysv-convert --save postgrey >/dev/null 2>&1 ||:
+
+# Run these because the SysV package being removed won't do them
+/sbin/chkconfig --del postgrey >/dev/null 2>&1 || :
+/bin/systemctl try-restart postgrey.service >/dev/null 2>&1 || :
%files
%defattr(-,root,root,-)
%doc Changes COPYING README README-rpm
-%{_sysconfdir}/rc.d/init.d/postgrey
+%{_unitdir}/postgrey.service
+%{_sysconfdir}/sysconfig/postgrey
%config(noreplace) %{confdir}/postgrey_whitelist_clients
%config(noreplace) %{confdir}/postgrey_whitelist_recipients
%config(noreplace) %{confdir}/postgrey_whitelist_clients.local
@@ -112,6 +144,9 @@ fi
%changelog
+* Tue Mar 20 2012 Jon Ciesla <limburgher at gmail.com> - 1.34-3
+- Migrate to systemd, BZ 714430.
+
* Sat Jan 14 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1.34-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
diff --git a/postgrey.sysconfig b/postgrey.sysconfig
new file mode 100644
index 0000000..f735afd
--- /dev/null
+++ b/postgrey.sysconfig
@@ -0,0 +1 @@
+POSTGREY_OPTS="--delay=60"
More information about the scm-commits
mailing list