[apg] Convert to systemd. Fixes bug #737168

Kevin Fenzi kevin at fedoraproject.org
Sun Jan 29 05:43:36 UTC 2012


commit f0957100c2f17666832a8477416fd810cee4fa2a
Author: Kevin Fenzi <kevin at scrye.com>
Date:   Sat Jan 28 22:42:59 2012 -0700

    Convert to systemd. Fixes bug #737168

 apg.socket   |    9 +++++++++
 apg.spec     |   39 ++++++++++++++++++++++++++++++++++-----
 apg at .service |    7 +++++++
 3 files changed, 50 insertions(+), 5 deletions(-)
---
diff --git a/apg.socket b/apg.socket
new file mode 100644
index 0000000..74fd012
--- /dev/null
+++ b/apg.socket
@@ -0,0 +1,9 @@
+[Unit]
+Description=Apg Activation Socket
+
+[Socket]
+ListenStream=129
+Accept=true
+
+[Install]
+WantedBy=sockets.target
diff --git a/apg.spec b/apg.spec
index c8684e6..7a141d8 100644
--- a/apg.spec
+++ b/apg.spec
@@ -2,17 +2,22 @@ Summary:		Automated Password Generator for random password generation
 Name:			apg
 
 Version:		2.3.0b
-Release:		12%{?dist}
+Release:		13%{?dist}
 License:		BSD
 Group:			System Environment/Base
 URL:			http://www.adel.nursat.kz/%{name}/
 
 Source0:		http://www.adel.nursat.kz/%{name}/download/%{name}-%{version}.tar.gz
-Source1:		apg.xinetd
+Source1:		apg.socket
+Source2:		apg at .service
 Patch0:			apg-2.3.0b-gen_rand_pass.patch
 
 BuildRoot:		%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+BuildRequires: systemd-units
 Requires(post): grep
+Requires(post): systemd-units
+Requires(preun): systemd-units
+Requires(postun): systemd-units
 
 %description
 APG (Automated Password Generator) is the tool set for random password
@@ -38,18 +43,38 @@ install -D apgd %{buildroot}%{_sbindir}/apgd
 install -D -m 644 doc/man/apg.1 %{buildroot}%{_mandir}/man1/apg.1
 install -D -m 644 doc/man/apgbfm.1 %{buildroot}%{_mandir}/man1/apgbfm.1
 install -D -m 644 doc/man/apgd.8 %{buildroot}%{_mandir}/man8/apgd.8
+install -d -m 755 %{buildroot}%{_unitdir}
 
-install -D -m 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/xinetd.d/apgd
+install -p -m 755 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.socket
+install -p -m 755 %{SOURCE2} %{buildroot}%{_unitdir}/%{name}@.service
 
 %clean
 [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
 
 %post
 # add a service for apg if it doesn't already exist
-if ! grep -q ^pwdgen /etc/services; then
+/bin/grep ^pwgen /etc/services >& /dev/null
+if [ $? == 1 ]; then
     echo -e 'pwdgen\t\t129/tcp\t\t\t# PWDGEN service' >> /etc/services
 fi
+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
+    /bin/systemctl --no-reload disable apg at .service > /dev/null 2>&1 || :
+    /bin/systemctl stop apg at .service > /dev/null 2>&1 || :
+fi
+
+%postun
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+if [ $1 -ge 1 ] ; then
+    # Package upgrade, not uninstall
+    /bin/systemctl try-restart apg at .service >/dev/null 2>&1 || :
+fi
 
 %files
 %defattr(-, root, root)
@@ -58,9 +83,13 @@ fi
 %{_bindir}/apgbfm
 %{_sbindir}/apgd
 %{_mandir}/man*/*
-%{_sysconfdir}/xinetd.d/apgd
+%{_unitdir}/%{name}@.service
+%{_unitdir}/%{name}.socket
 
 %changelog
+* Sat Jan 28 2012 Kevin Fenzi <kevin at scrye.com> 2.3.0b-13
+- Convert to use systemd instead of xinetd. Fixes bug #737168
+
 * Thu Jan 12 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 2.3.0b-12
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
 
diff --git a/apg at .service b/apg at .service
new file mode 100644
index 0000000..beafcb2
--- /dev/null
+++ b/apg at .service
@@ -0,0 +1,7 @@
+[Unit]
+Description=Apgd Random Passwords Generator Server
+After=local-fs.target
+
+[Service]
+ExecStart=/usr/sbin/apgd -M sncl -EO -a 0 -r /usr/share/dict/words -m 8 -x 8 -t
+StandardInput=socket


More information about the scm-commits mailing list