[newscache] Migrate to systemd

Dmitry Butskoy buc at fedoraproject.org
Fri Jul 15 13:27:55 UTC 2011


commit 946408c4a9866b8cff3eed661615c82a68fbd4ea
Author: Dmitry Butskoy <Dmitry at Butskoy.name>
Date:   Fri Jul 15 17:27:20 2011 +0400

    Migrate to systemd

 newscache.service |   12 ++++++++++++
 newscache.spec    |   33 ++++++++++++++++++++++-----------
 2 files changed, 34 insertions(+), 11 deletions(-)
---
diff --git a/newscache.service b/newscache.service
new file mode 100644
index 0000000..3f3fe36
--- /dev/null
+++ b/newscache.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=NewsCache cache server for USENET News.
+After=syslog.target network.target
+
+[Service]
+Type=forking
+PIDFile=/var/run/newscache.pid
+ExecStart=/usr/sbin/newscache
+ExecReload=/bin/kill -HUP $MAINPID
+
+[Install]
+WantedBy=multi-user.target
diff --git a/newscache.spec b/newscache.spec
index 749f219..8934501 100644
--- a/newscache.spec
+++ b/newscache.spec
@@ -4,13 +4,14 @@
 Name: 		newscache
 Summary: 	Free cache server for USENET News
 Version: 	1.2
-Release: 	0.12.rc6%{?dist}
+Release: 	0.13.rc6%{?dist}
 Group: 		System Environment/Daemons
 License:	GPLv2+
 URL:		http://www.linuxhacker.at/newscache/
 Source0: 	http://src.linuxhacker.at/NewsCache/%{srcnamever}.tar.gz
 Source1:	http://src.linuxhacker.at/socket++/socket++-%{socketver}.tar.gz
 Source2:	%{name}.init
+Source3:	%{name}.service
 BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 Patch1:		newscache-1.2rc6-config.patch
 Patch2:		newscache-1.2rc6-gcc43.patch
@@ -18,9 +19,9 @@ Patch3:		socket++-1.12.12-autotools.patch
 BuildRequires:	libtool, texinfo, pam-devel
 
 Requires(pre): shadow-utils
-Requires(post):	/sbin/chkconfig
-Requires(preun): /sbin/chkconfig, /sbin/service
-Requires(postun): /sbin/service
+Requires(post):	systemd-units
+Requires(preun): systemd-units
+Requires(postun): systemd-units
 
 
 
@@ -87,8 +88,11 @@ install -d $RPM_BUILD_ROOT%{_localstatedir}/cache/newscache
 install -d $RPM_BUILD_ROOT%{_sysconfdir}
 install -m644 -p newscache.conf $RPM_BUILD_ROOT%{_sysconfdir}/%{name}.conf
 
-install -d $RPM_BUILD_ROOT%{_initrddir}
-install -m755 -p %SOURCE2 $RPM_BUILD_ROOT%{_initrddir}/%{name}
+#install -d $RPM_BUILD_ROOT%{_initrddir}
+#install -m755 -p %SOURCE2 $RPM_BUILD_ROOT%{_initrddir}/%{name}
+
+install -d $RPM_BUILD_ROOT%{_unitdir}
+install -p -m644 %SOURCE3 $RPM_BUILD_ROOT%{_unitdir}/%{name}.service
 
 install -d $RPM_BUILD_ROOT%{_sysconfdir}/pam.d
 pushd $RPM_BUILD_ROOT%{_sysconfdir}/pam.d
@@ -121,19 +125,22 @@ exit 0
 
 %post
 
-/sbin/chkconfig --add %{name}
+if [ $1 = 1 ]; then
+    /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+fi
 
 
 %preun
 if [ $1 = 0 ]; then
-   /sbin/service %{name} stop >/dev/null 2>&1
-   /sbin/chkconfig --del %{name}
+    /bin/systemctl --no-reload disable %{name}.service >/dev/null 2>&1 || :
+    /bin/systemctl stop %{name}.service >/dev/null 2>&1 || :
 fi
 
 
 %postun
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
 if [ $1 != 0 ]; then
-   /sbin/service %{name} condrestart >/dev/null 2>&1
+    /bin/systemctl try-restart %{name}.service >/dev/null 2>&1 || :
 fi
 
 
@@ -145,9 +152,10 @@ rm -rf $RPM_BUILD_ROOT
 %defattr(-,root,root)
 %attr(755,news,news) %dir %{_localstatedir}/cache/newscache
 %config(noreplace) %{_sysconfdir}/%{name}.conf
-%config(noreplace) %{_initrddir}/*
 %config(noreplace) %{_sysconfdir}/pam.d/*
 %config(noreplace) %{_sysconfdir}/cron.daily/*
+#%config(noreplace) %{_initrddir}/*
+%{_unitdir}/%{name}.service
 %{_bindir}/*
 %{_sbindir}/*
 %doc AUTHORS COPYING NEWS README THANKS TODO
@@ -156,6 +164,9 @@ rm -rf $RPM_BUILD_ROOT
 
 
 %changelog
+* Fri Jul 15 2011 Dmitry Butskoy <Dmitry at Butskoy.name> - 1.2-0.13.rc6
+- Migration from SysV to Systemd init system (#699038)
+
 * Tue Feb 08 2011 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1.2-0.12.rc6
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
 


More information about the scm-commits mailing list