[xinetd] convert to systemd

Tom Callaway spot at fedoraproject.org
Mon Sep 12 13:49:13 UTC 2011


commit 0ed034f7e8b8372cb268f2f654fe066680299c86
Author: Tom "spot" Callaway <tcallawa at redhat.com>
Date:   Mon Sep 12 09:49:00 2011 -0400

    convert to systemd

 xinetd.service |   13 +++++++++++++
 xinetd.spec    |   55 +++++++++++++++++++++++++++++++++++--------------------
 2 files changed, 48 insertions(+), 20 deletions(-)
---
diff --git a/xinetd.service b/xinetd.service
new file mode 100644
index 0000000..cd8dadc
--- /dev/null
+++ b/xinetd.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Xinetd A Powerful Replacement For Inetd
+After=syslog.target network.target
+
+[Service]
+Type=forking
+PIDFile=/var/run/xinetd.pid
+EnvironmentFile=-/etc/sysconfig/xinetd
+ExecStart=/usr/sbin/xinetd -stayalive -pidfile /var/run/xinetd.pid "$EXTRAOPTIONS"
+
+[Install]
+WantedBy=multi-user.target
+
diff --git a/xinetd.spec b/xinetd.spec
index 8a94d6c..8d6f076 100644
--- a/xinetd.spec
+++ b/xinetd.spec
@@ -1,13 +1,13 @@
 Summary: A secure replacement for inetd
 Name: xinetd
 Version: 2.3.14
-Release: 36%{?dist}
+Release: 37%{?dist}
 License: xinetd 
 Group: System Environment/Daemons
 Epoch: 2
 URL: http://www.xinetd.org
 Source: http://www.xinetd.org/xinetd-%{version}.tar.gz
-Source1: xinetd.init
+Source1: xinetd.service
 Source3: xinetd.sysconf
 Patch0: xinetd-2.3.11-pie.patch
 Patch1: xinetd-2.3.12-tcp_rpc.patch
@@ -46,11 +46,15 @@ Patch20: xinetd-2.3.14-fix-type-punned-ptr.patch
 
 BuildRequires: autoconf, automake
 BuildRequires: libselinux-devel >= 1.30
-Requires: /sbin/chkconfig /etc/init.d /sbin/service
+BuildRequires: systemd-units
+Requires(post): systemd-sysv
+Requires(post): systemd-units
+Requires(preun): systemd-units
+Requires(postun): systemd-units
 %{!?tcp_wrappers:BuildRequires: tcp_wrappers-devel}
 Requires: filesystem >= 2.0.1, initscripts, setup, fileutils
 Provides: inetd
-BuildRoot: %{_tmppath}/%{name}-%{version}-root
+
 
 %description
 Xinetd is a secure replacement for inetd, the Internet services
@@ -102,15 +106,14 @@ export LDFLAGS="$LDFLAGS -Wl,-z,relro,-z,now"
 make
 
 %install
-rm -rf $RPM_BUILD_ROOT
-mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
+mkdir -p $RPM_BUILD_ROOT%{_unitdir}
 mkdir -p $RPM_BUILD_ROOT/etc/xinetd.d/
 # Remove unneeded service
 rm -f contrib/xinetd.d/ftp-sensor
 %makeinstall DAEMONDIR=$RPM_BUILD_ROOT/usr/sbin MANDIR=$RPM_BUILD_ROOT/%{_mandir}
 install -m 644 contrib/xinetd.conf $RPM_BUILD_ROOT/etc
 install -m 644 contrib/xinetd.d/* $RPM_BUILD_ROOT/etc/xinetd.d
-install -m 755 %SOURCE1 $RPM_BUILD_ROOT/etc/rc.d/init.d/xinetd
+install -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_unitdir}
 
 rm -f $RPM_BUILD_ROOT/%{_mandir}/man8/itox*
 rm -f $RPM_BUILD_ROOT/usr/sbin/itox
@@ -120,38 +123,50 @@ rm -f $RPM_BUILD_ROOT/usr/sbin/xconv.pl
 mkdir -p $RPM_BUILD_ROOT/etc/sysconfig
 install -m 644 %SOURCE3 $RPM_BUILD_ROOT/etc/sysconfig/xinetd
 
-%clean
-rm -rf $RPM_BUILD_ROOT
-
 %post
-if [ $1 = 1 ]; then
-    /sbin/chkconfig --add xinetd 
+if [ $1 -eq 1 ] ; then 
+    # Initial installation
+    /bin/systemctl enable xinetd.service >/dev/null 2>&1 || :
 fi
 
 %preun
-if [ $1 = 0 ]; then
-    /sbin/service xinetd stop > /dev/null 2>&1
-    /sbin/chkconfig --del xinetd 
+if [ $1 -eq 0 ] ; then
+    # Package removal, not upgrade
+    /bin/systemctl --no-reload disable xinetd.service > /dev/null 2>&1 || :
+    /bin/systemctl stop xinetd.service > /dev/null 2>&1 || :
 fi
 
 %postun
-if [ $1 -ge 1 ]; then
-    /sbin/service xinetd 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 xinetd.service >/dev/null 2>&1 || :
 fi
 
+%triggerun -- xinetd < 2:2.3.14-37
+# Save the current service runlevel info
+# User must manually run systemd-sysv-convert --apply xinetd
+# to migrate them to systemd targets
+/usr/bin/systemd-sysv-convert --save xinetd >/dev/null 2>&1 ||:
+/bin/systemctl --no-reload enable xinetd.service >/dev/null 2>&1 ||:
+
+# Run these because the SysV package being removed won't do them
+/sbin/chkconfig --del xinetd >/dev/null 2>&1 || :
+/bin/systemctl try-restart xinetd.service >/dev/null 2>&1 || :
 
 %files
-%defattr(-,root,root)
 %doc INSTALL CHANGELOG COPYRIGHT README xinetd/sample.conf contrib/empty.conf 
-
 %config(noreplace) /etc/xinetd.conf
 %config(noreplace) /etc/sysconfig/xinetd
-/etc/rc.d/init.d/xinetd
+%{_unitdir}/xinetd.service
 %config(noreplace) /etc/xinetd.d/*
 /usr/sbin/xinetd
 %{_mandir}/*/*
 
 %changelog
+* Mon Sep 12 2011 Tom Callaway <spot at fedoraproject.org> - 2:2.3.14-37
+- covert to systemd
+
 * Thu Apr 21 2011 Vojtech Vitek (V-Teq) <vvitek at redhat.com> - 2:2.3.14-36
 - Fix build warning about "dereferencing type-punned pointer"
   Related: #695674


More information about the scm-commits mailing list