[portreserve] Converted initscript to systemd service file (bug #617331).
Tim Waugh
twaugh at fedoraproject.org
Tue Jul 12 15:51:26 UTC 2011
commit 2678f3292cdb7c434064059acb28a472f73433f1
Author: Tim Waugh <twaugh at redhat.com>
Date: Tue Jul 12 16:50:47 2011 +0100
Converted initscript to systemd service file (bug #617331).
portreserve.service | 15 +++++++++++++++
portreserve.spec | 48 ++++++++++++++++++++++++++++++++++++------------
2 files changed, 51 insertions(+), 12 deletions(-)
---
diff --git a/portreserve.service b/portreserve.service
new file mode 100644
index 0000000..284c9b8
--- /dev/null
+++ b/portreserve.service
@@ -0,0 +1,15 @@
+[Unit]
+Description=Port reservation utility
+After=sockets.target
+Before=basic.target shutdown.target
+Conflicts=shutdown.target
+DefaultDependencies=no
+
+[Service]
+Type=forking
+PIDFile=/var/run/portreserve.pid
+ExecStart=/sbin/portreserve
+Restart=no
+
+[Install]
+WantedBy=multi-user.target
diff --git a/portreserve.spec b/portreserve.spec
index a077ce3..12df363 100644
--- a/portreserve.spec
+++ b/portreserve.spec
@@ -1,16 +1,23 @@
Summary: TCP port reservation utility
Name: portreserve
Version: 0.0.5
-Release: 2%{?dist}
+Release: 3%{?dist}
License: GPLv2+
Group: System Environment/Daemons
URL: http://cyberelk.net/tim/portreserve/
Source0: http://cyberelk.net/tim/data/portreserve/stable/%{name}-%{version}.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-Requires(post): chkconfig
-Requires(preun): chkconfig
+Requires(post): systemd-units
+Requires(preun): systemd-units
+Requires(postun): systemd-units
+
+# This is actually needed for the %triggerun script but Requires(triggerun)
+# is not valid. We can use %post because this particular %triggerun script
+# should fire just after this package is installed.
+Requires(post): systemd-sysv
BuildRequires: xmlto
+BuildRequires: systemd-units
Obsoletes: portreserve-selinux < 0.0.3-3
%description
@@ -42,32 +49,49 @@ EOF
rm -rf %{buildroot}
%post
-# Do this unconditionally to fix up the initscript's start priority.
-# Earlier versions had an incorrect dependency (bug #487250).
-/sbin/chkconfig --add portreserve
+if [ $1 -eq 1 ] ; then
+ # Initial installation
+ /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+fi
%preun
-if [ "$1" = 0 ]; then
- /sbin/service portreserve stop >/dev/null 2>&1
- /sbin/chkconfig --del portreserve
+if [ $1 -eq 0 ] ; then
+ # Package removal, not upgrade
+ /bin/systemctl --no-reload disable portreserve.service >/dev/null 2>&1 || :
+ /bin/systemctl stop portreserve.service >/dev/null 2>&1 || :
fi
%postun
-if [ "$1" -ge "1" ]; then
- /sbin/service portreserve condrestart >/dev/null 2>&1
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+if [ $1 -ge 1 ] ; then
+ # Package upgrade, not uninstall
+ /bin/systemctl try-restart portreserve.service >/dev/null 2>&1 || :
fi
+%triggerun -- portreserve < 0.0.5-3
+# Save the current service runlevel info
+# User must manually run systemd-sysv-convert --apply portreserve
+# to migrate them to systemd targets
+%{_bindir}/systemd-sysv-convert --save portreserve >/dev/null 2>&1 ||:
+
+# Run these because the SysV package being removed won't do them
+/sbin/chkconfig --del portreserve >/dev/null 2>&1 || :
+/bin/systemctl try-restart portreserve.service >/dev/null 2>&1 || :
+
%files
%defattr(-,root,root)
%doc ChangeLog README COPYING NEWS
%ghost %dir %{_localstatedir}/run/portreserve
%dir %{_sysconfdir}/portreserve
%config %{_sysconfdir}/tmpfiles.d/portreserve.conf
-%attr(755,root,root) %{_initrddir}/portreserve
+%{_unitdir}/portreserve.service
/sbin/*
%{_mandir}/*/*
%changelog
+* Tue Jul 12 2011 Tim Waugh <twaugh at redhat.com> 0.0.5-3
+- Converted initscript to systemd service file (bug #617331).
+
* Fri Jul 1 2011 Tim Waugh <twaugh at redhat.com> 0.0.5-2
- Requires chkconfig (bug #718173).
More information about the scm-commits
mailing list