[nuttcp] - provide native systemd services - drop xinetd file

rvokal rvokal at fedoraproject.org
Wed Nov 23 08:14:53 UTC 2011


commit a23e3fc954b934d1d6edfb4f31a4b3f006b0242c
Author: Radek Vokál <rvokal at redhat.com>
Date:   Wed Nov 23 10:14:37 2011 +0100

     - provide native systemd services
     - drop xinetd file

 nuttcp-5.5.5-makefile.patch |   10 ---------
 nuttcp.socket               |    9 ++++++++
 nuttcp.spec                 |   45 ++++++++++++++++++++++++++++++++++++++----
 nuttcp at .service             |    8 +++++++
 4 files changed, 57 insertions(+), 15 deletions(-)
---
diff --git a/nuttcp.socket b/nuttcp.socket
new file mode 100644
index 0000000..a8ae74f
--- /dev/null
+++ b/nuttcp.socket
@@ -0,0 +1,9 @@
+[Unit]
+Description=Network Performance Testing Server Activation Socket
+
+[Socket]
+ListenStream=5000
+Accept=true
+
+[Install]
+WantedBy=sockets.target
diff --git a/nuttcp.spec b/nuttcp.spec
index bca2408..042b1f0 100644
--- a/nuttcp.spec
+++ b/nuttcp.spec
@@ -1,12 +1,18 @@
 Name: nuttcp
 Version: 6.1.2
-Release: 4%{?dist}
+Release: 5%{?dist}
 Source0: ftp://ftp.lcp.nrl.navy.mil/pub/nuttcp/%{name}-%{version}.tar.bz2
+Source1: %{name}@.service
+Source2: %{name}.socket
 URL: ftp://ftp.lcp.nrl.navy.mil/pub/nuttcp/
 Summary: Tool for testing TCP connections
 Group: Applications/Internet
 License: Public Domain
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+BuildRequires:		systemd-units
+Requires(post):		systemd-units
+Requires(preun):	systemd-units
+Requires(postun):	systemd-units
 
 %description
 nuttcp is a network performance measurement tool intended for use by
@@ -23,8 +29,8 @@ CPU utilization, and loss percentage (for UDP transfers).
 %prep
 %setup -q
 
-sed -i -e "s,/usr/local/bin,%{_bindir},g;" \
-       -e  "s,disable\(.*\)no,disable\t\t= yes,g" xinetd.d/*
+#sed -i -e "s,/usr/local/bin,%{_bindir},g;" \
+#       -e  "s,disable\(.*\)no,disable\t\t= yes,g" xinetd.d/*
 
 %build
 make CFLAGS="$RPM_OPT_FLAGS"
@@ -34,19 +40,48 @@ rm -fr $RPM_BUILD_ROOT
 mkdir -p $RPM_BUILD_ROOT{%{_mandir}/man8,%{_bindir},%{_sysconfdir}/xinetd.d}
 install -m755 %{name}-%{version} $RPM_BUILD_ROOT%{_bindir}/%{name}
 install -pm644 %{name}.8 $RPM_BUILD_ROOT%{_mandir}/man8
-install -pm644 xinetd.d/%{name} $RPM_BUILD_ROOT%{_sysconfdir}/xinetd.d/
+mkdir -p %{buildroot}%{_unitdir}
+install -m644 %{SOURCE1} $RPM_BUILD_ROOT%{_unitdir}
+install -m644 %{SOURCE2} $RPM_BUILD_ROOT%{_unitdir}
 
 %clean
 rm -fr $RPM_BUILD_ROOT
 
+%post
+if [ $1 -eq 1 ] ; then
+    # Initial installation
+    /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+fi
+
+%preun
+if [ $1 -eq 0 ]; then
+        #Package removal, not upgrade
+        systemctl --no-reload disable %{name}@.service >/dev/null 2>&1 || :
+        systemctl stop %{name}@.service >/dev/null 2>&1 || :
+        /sbin/install-info --del %{_infodir}/uucp.info.gz %{_infodir}/dir || :
+fi
+
+%postun
+if [ $1 -ge 1 ]; then
+        #Package upgrade, not uninstall
+        systemctl try-restart %{name}@.service >/dev/null 2>&1
+fi
+
+
 %files
 %defattr(-,root,root)
 %doc README examples.txt nuttcp.html xinetd.d/nuttcp4 xinetd.d/nuttcp6
 %{_bindir}/%{name}
 %{_mandir}/man8/*
-%config(noreplace) %{_sysconfdir}/xinetd.d/%{name}
+%{_unitdir}/%{name}@.service
+%{_unitdir}/%{name}.socket
+
 
 %changelog
+* Wed Nov 23 2011 Radek Vokal <rvokal at redhat.com> - 6.1.2-5
+- provide native systemd services (#737705)
+- drop xinetd file
+
 * Mon Feb 14 2011 Radek Vokal <rvokal at redhat.com> - 6.1.2-1
 - upgrade to 6.1.2
 
diff --git a/nuttcp at .service b/nuttcp at .service
new file mode 100644
index 0000000..b778e85
--- /dev/null
+++ b/nuttcp at .service
@@ -0,0 +1,8 @@
+[Unit]
+Description=Network Performance Testing Server
+After=local-fs.target
+
+[Service]
+User=nobody
+ExecStart=/usr/bin/nuttcp -S
+StandardInput=socket


More information about the scm-commits mailing list