[pdns-recursor] convert to systemd

Tom Callaway spot at fedoraproject.org
Mon Sep 12 18:57:48 UTC 2011


commit 046159970f22107262e30342ae79bc988e7dd1a6
Author: Tom "spot" Callaway <tcallawa at redhat.com>
Date:   Mon Sep 12 14:57:37 2011 -0400

    convert to systemd

 pdns-recursor.service |   10 ++++++++++
 pdns-recursor.spec    |   49 +++++++++++++++++++++++++++++++++----------------
 2 files changed, 43 insertions(+), 16 deletions(-)
---
diff --git a/pdns-recursor.service b/pdns-recursor.service
new file mode 100644
index 0000000..7f4f02b
--- /dev/null
+++ b/pdns-recursor.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=PDNS Recursor
+After=syslog.target network.target
+
+[Service]
+Type=forking
+ExecStart=/usr/sbin/pdns_recursor --daemon
+
+[Install]
+WantedBy=multi-user.target
diff --git a/pdns-recursor.spec b/pdns-recursor.spec
index cd5c5c7..c353044 100644
--- a/pdns-recursor.spec
+++ b/pdns-recursor.spec
@@ -1,21 +1,24 @@
 Summary:		Modern, advanced and high performance recursing/non authoritative nameserver
 Name:			pdns-recursor
 Version:		3.3
-Release:		3%{?dist}
+Release:		4%{?dist}
 Group:			System Environment/Daemons
 License:		GPLv2
 URL:			http://powerdns.com
 Source0:		http://downloads.powerdns.com/releases/%{name}-%{version}.tar.bz2
-Source1:		pdns-recursor.init	
+Source1:		pdns-recursor.service	
 
 Patch0:			pdns-recursor-fixmakefile.patch
 Patch1:			pdns-recursor-fixsysconfdir.patch
 
 Provides:		powerdns-recursor = %{version}-%{release}
 BuildRequires:		boost-devel, lua-devel
+BuildRequires:		systemd-units
 Requires(pre):          shadow-utils
-Requires(post):		chkconfig
-Requires(preun):	chkconfig, initscripts 
+Requires(post):		systemd-sysv
+Requires(post):		systemd-units
+Requires(preun):	systemd-units
+Requires(postun):	systemd-units
 
 %description
 PowerDNS Recursor is a non authoritative/recursing DNS server. Use this
@@ -31,9 +34,8 @@ LUA=1 LUA_CPPFLAGS_CONFIG= LUA_LIBS_CONFIG=-llua OPTFLAGS="%{optflags}" make %{?
 
 
 %install
-%{__rm} -rf %{buildroot}
 make install DESTDIR=%{buildroot} CONFIGDIR="%{_sysconfdir}/%{name}"
-%{__install} -D -p %{SOURCE1} %{buildroot}%{_initrddir}/pdns-recursor
+%{__install} -D -p %{SOURCE1} %{buildroot}%{_unitdir}/pdns-recursor.service
 
 %{__mv} %{buildroot}%{_sysconfdir}/%{name}/recursor.conf{-dist,}
 
@@ -49,35 +51,50 @@ getent passwd pdns-recursor > /dev/null || \
 exit 0
 
 %post
-chkconfig --add %{name}
+if [ $1 -eq 1 ] ; then 
+    # Initial installation 
+    /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+fi
 
 %preun
-if [ $1 -eq 0 ]; then
-    service %{name} stop >/dev/null 2>&1 || :
-    chkconfig --del %{name}
+if [ $1 -eq 0 ] ; then
+    # Package removal, not upgrade
+    /bin/systemctl --no-reload disable pdns-recursor.service > /dev/null 2>&1 || :
+    /bin/systemctl stop pdns-recursor.service > /dev/null 2>&1 || :
 fi
 
 %postun
-if [ $1 -ge 1 ]; then
-    service %{name} 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 pdns-recursor.service >/dev/null 2>&1 || :
 fi
 
-%clean
-%{__rm} -rf %{buildroot}
+%triggerun -- pdns-recursor < 3.3-4
+# Save the current service runlevel info
+# User must manually run systemd-sysv-convert --apply pdns-recursor
+# to migrate them to systemd targets
+/usr/bin/systemd-sysv-convert --save pdns-recursor >/dev/null 2>&1 ||:
+
+# Run these because the SysV package being removed won't do them
+/sbin/chkconfig --del pdns-recursor >/dev/null 2>&1 || :
+/bin/systemctl try-restart pdns-recursor.service >/dev/null 2>&1 || :
 
 %files
-%defattr(-,root,root,-)
 %{_bindir}/rec_control
 %{_sbindir}/pdns_recursor
 %{_mandir}/man1/pdns_recursor.1.gz
 %{_mandir}/man1/rec_control.1.gz
-%{_initrddir}/pdns-recursor
+%{_unitdir}/pdns-recursor.service
 %dir %{_sysconfdir}/%{name}
 %config(noreplace) %{_sysconfdir}/%{name}/recursor.conf
 %doc COPYING README
 
 
 %changelog
+* Mon Sep 12 2011 Tom Callaway <spot at fedoraproject.org> - 3.3-4
+- convert to systemd
+
 * Tue Feb 08 2011 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 3.3-3
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
 


More information about the scm-commits mailing list