[nsd] convert to systemd
Tom Callaway
spot at fedoraproject.org
Mon Sep 12 18:15:35 UTC 2011
commit 3dd0f65720162b8a27ad363ffa7b8c23ac13e1d6
Author: Tom "spot" Callaway <tcallawa at redhat.com>
Date: Mon Sep 12 14:15:22 2011 -0400
convert to systemd
nsd.service | 19 ++++++++++++++++
nsd.spec | 61 ++++++++++++++++++++++++++++++++++++----------------
tmpfiles-nsd.conf | 1 +
3 files changed, 62 insertions(+), 19 deletions(-)
---
diff --git a/nsd.service b/nsd.service
new file mode 100644
index 0000000..54f0952
--- /dev/null
+++ b/nsd.service
@@ -0,0 +1,19 @@
+[Unit]
+Description=NSD DNS Server
+After=syslog.target network.target
+
+[Service]
+Type=forking
+PIDFile=/var/run/nsd/nsd.pid
+EnvironmentFile=-/etc/sysconfig/nsd
+ExecStartPre=/usr/sbin/nsdc -c /etc/nsd/nsd.conf rebuild
+ExecStart=/usr/sbin/nsd -c /etc/nsd/nsd.conf $OTHER_NSD_OPTS
+ExecReload=/usr/sbin/nsdc -c /etc/nsd/nsd.conf rebuild
+ExecReload=/usr/sbin/nsdc -c /etc/nsd/nsd.conf reload
+ExecStop=/usr/sbin/nsdc -c /etc/nsd/nsd.conf patch
+ExecStop=/usr/sbin/nsdc -c /etc/nsd/nsd.conf stop
+ExecStopPost=/bin/rm -f /var/lib/nsd/xfrd.state
+
+[Install]
+WantedBy=multi-user.target
+
diff --git a/nsd.spec b/nsd.spec
index f19a22a..6ffaa6d 100644
--- a/nsd.spec
+++ b/nsd.spec
@@ -1,18 +1,23 @@
Summary: Fast and lean authoritative DNS Name Server
Name: nsd
Version: 3.2.8
-Release: 5%{?dist}
+Release: 6%{?dist}
License: BSD
Url: http://www.nlnetlabs.nl/%{name}/
Source: http://www.nlnetlabs.nl/downloads/%{name}/%{name}-%{version}.tar.gz
-Source1: nsd.init
+Source1: nsd.service
Source2: nsd.cron
Source3: nsd.sysconfig
+Source4: tmpfiles-nsd.conf
Patch0: nsd-install.patch
Patch1: nsd-fixlogfile.patch
Group: System Environment/Daemons
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: flex, openssl-devel
+BuildRequires: systemd-units
+Requires(post): systemd-sysv
+Requires(post): systemd-units
+Requires(preun): systemd-units
+Requires(postun): systemd-units
Requires(pre): shadow-utils
%description
@@ -42,16 +47,17 @@ mv -f doc/CREDITS.utf8 doc/CREDITS
%install
-rm -rf %{buildroot}
%{__make} DESTDIR=%{buildroot} install
-install -d -m 0755 %{buildroot}%{_initrddir}
-install -d -m 0755 $RPM_BUILD_ROOT%{_sysconfdir}/cron.hourly
-install -c -m 0755 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/cron.hourly/nsd
-install -m 0755 %{SOURCE1} %{buildroot}/%{_initrddir}/nsd
+mkdir -p %{buildroot}%{_unitdir}
+install -d -m 0755 %{buildroot}%{_sysconfdir}/cron.hourly
+install -c -m 0755 %{SOURCE2} %{buildroot}%{_sysconfdir}/cron.hourly/nsd
+install -m 0755 %{SOURCE1} %{buildroot}/%{_unitdir}/nsd.service
install -d -m 0755 %{buildroot}%{_localstatedir}/run/%{name}
install -d -m 0700 %{buildroot}%{_localstatedir}/lib/%{name}
install -d -m 0755 %{buildroot}%{_sysconfdir}/sysconfig
install -m 0755 %{SOURCE3} %{buildroot}/%{_sysconfdir}/sysconfig/%{name}
+mkdir -p %{buildroot}%{_sysconfdir}/tmpfiles.d/
+install -m 0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/tmpfiles.d/nsd.conf
# change .sample to normal config files
head -76 %{buildroot}%{_sysconfdir}/nsd/nsd.conf.sample > %{buildroot}%{_sysconfdir}/nsd/nsd.conf
@@ -59,17 +65,14 @@ rm %{buildroot}%{_sysconfdir}/nsd/nsd.conf.sample
echo "database: /var/lib/nsd/nsd.db" >> %{buildroot}%{_sysconfdir}/nsd/nsd.conf
echo "# include: \"/some/path/file\"" >> %{buildroot}%{_sysconfdir}/nsd/nsd.conf
-%clean
-rm -rf ${RPM_BUILD_ROOT}
-
%files
-%defattr(-,root,root,-)
%doc doc/*
%doc contrib/nsd.zones2nsd.conf
%dir %{_sysconfdir}/nsd/
%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/nsd/nsd.conf
%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/sysconfig/nsd
-%attr(0755,root,root) %{_initrddir}/%{name}
+%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/tmpfiles.d/nsd.conf
+%{_unitdir}/%{name}.service
%{_sysconfdir}/cron.hourly/nsd
%ghost %attr(0755,root,root) %dir %{_localstatedir}/run/%{name}
%attr(0755,%{name},%{name}) %dir %{_localstatedir}/lib/%{name}
@@ -84,20 +87,40 @@ useradd -r -g nsd -d /etc/nsd -s /sbin/nologin \
exit 0
%post
-/sbin/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
- /sbin/service %{name} stop
- /sbin/chkconfig --del %{name}
+if [ $1 -eq 0 ] ; then
+ # Package removal, not upgrade
+ /bin/systemctl --no-reload disable nsd.service > /dev/null 2>&1 || :
+ /bin/systemctl stop nsd.service > /dev/null 2>&1 || :
fi
%postun
-if [ "$1" -ge "1" ]; then
- /sbin/service %{name} condrestart
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+if [ $1 -ge 1 ] ; then
+ # Package upgrade, not uninstall
+ /bin/systemctl try-restart nsd.service >/dev/null 2>&1 || :
fi
+%triggerun -- nsd < 3.2.8-6
+# Save the current service runlevel info
+# User must manually run systemd-sysv-convert --apply nsd
+# to migrate them to systemd targets
+/usr/bin/systemd-sysv-convert --save nsd >/dev/null 2>&1 ||:
+
+# Run these because the SysV package being removed won't do them
+/sbin/chkconfig --del nsd >/dev/null 2>&1 || :
+/bin/systemctl try-restart nsd.service >/dev/null 2>&1 || :
+
+
%changelog
+* Mon Sep 12 2011 Tom Callaway <spot at fedoraproject.org> - 3.2.8-6
+- convert to systemd, tmpfiles.d
+
* Fri Jun 3 2011 Paul Wouters <paul at xelerance.com> - 3.2.8-5
- fix /var/run/nsd to be owned by root, not nsd
diff --git a/tmpfiles-nsd.conf b/tmpfiles-nsd.conf
new file mode 100644
index 0000000..b5e5e6f
--- /dev/null
+++ b/tmpfiles-nsd.conf
@@ -0,0 +1 @@
+d /var/run/nsd 0755 nsd nsd -
More information about the scm-commits
mailing list