[quota] Migrate quota_nld service from sysvinit to systemd

Petr Pisar ppisar at fedoraproject.org
Thu Sep 1 14:08:03 UTC 2011


commit 4d57643f9e27b9ee102cf63d18801a4d97eaafe4
Author: Petr Písař <ppisar at redhat.com>
Date:   Wed Aug 31 18:37:39 2011 +0200

    Migrate quota_nld service from sysvinit to systemd

 quota.spec        |   44 +++++++++++++++++------
 quota_nld.init    |  104 -----------------------------------------------------
 quota_nld.service |   12 ++++++
 3 files changed, 45 insertions(+), 115 deletions(-)
---
diff --git a/quota.spec b/quota.spec
index f07b8ff..24b9e7e 100644
--- a/quota.spec
+++ b/quota.spec
@@ -14,8 +14,9 @@ Requires: quota-nls = %{epoch}:%{version}-%{release}
 Conflicts: kernel < 2.4
 BuildRequires: e2fsprogs-devel gettext tcp_wrappers-devel
 BuildRequires: openldap-devel dbus-devel libnl-devel
+BuildRequires: systemd-units
 Source0: http://downloads.sourceforge.net/linuxquota/%{name}-%{version}.tar.gz
-Source1: quota_nld.init
+Source1: quota_nld.service
 Source2: quota_nld.sysconfig
 # Not accepted changes (378a64006bb1e818e84a1c77808563b802b028fa)
 # Some of the lines have been superseded by other commits probably.
@@ -41,10 +42,10 @@ and limiting user and or group disk usage per file system.
 %package nld
 Summary: quota_nld daemon
 Group: System Environment/Base
-Requires: initscripts
 Requires: quota-nls = %{epoch}:%{version}-%{release}
-Requires(post): chkconfig
-Requires(preun): chkconfig initscripts
+Requires(post): systemd-sysv systemd-units
+Requires(preun): systemd-units
+Requires(postun): systemd-units
 
 %description nld
 Daemon that listens on netlink socket and processes received quota warnings.
@@ -158,7 +159,7 @@ ln -s  quotaon.8.gz \
 ln -s rquotad.8.gz \
    %{buildroot}%{_mandir}/man8/rpc.rquotad.8
 
-install -p -m755 -D %{SOURCE1} $RPM_BUILD_ROOT%{_initrddir}/quota_nld
+install -p -m644 -D %{SOURCE1} $RPM_BUILD_ROOT%{_unitdir}/quota_nld.service
 install -p -m644 -D %{SOURCE2} \
     $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/quota_nld
 
@@ -166,14 +167,34 @@ install -p -m644 -D %{SOURCE2} \
 
 
 %post nld
-/sbin/chkconfig --add quota_nld
+if [ $1 -eq 1 ] ; then
+    # Initial installation
+    /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+fi
 
 %preun nld
-if [ $1 = 0 ] ; then
-    /sbin/service quota_nld stop >/dev/null 2>&1
-    /sbin/chkconfig --del quota_nld
+if [ $1 -eq 0 ] ; then
+    # Package removal, not upgrade
+    /bin/systemctl --no-reload disable quota_nld.service > /dev/null 2>&1 || :
+    /bin/systemctl stop quota_nld.service > /dev/null 2>&1 || :
+fi
+
+%postun nld
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+if [ $1 -ge 1 ] ; then
+    # Package upgrade, not uninstall
+    /bin/systemctl try-restart quota_nld.service >/dev/null 2>&1 || :
 fi
 
+%triggerun -- %{name}-nld < 1:4.00-2
+echo 'quota-nld: User must migrate to systemd target manually by runnig:'
+echo '  systemd-sysv-convert --apply quota_nld'
+# Save the current service runlevel info
+/usr/bin/systemd-sysv-convert --save quota_nld >/dev/null 2>&1 || :
+# Run these because the SysV package being removed won't do them
+/sbin/chkconfig --del quota_nld >/dev/null 2>&1 || :
+/bin/systemctl try-restart quota_nld.service >/dev/null 2>&1 || :
+
 
 %files
 %attr(0755,root,root) /sbin/*
@@ -189,7 +210,7 @@ fi
 
 %files nld
 %config(noreplace) %attr(0644,root,root) %{_sysconfdir}/sysconfig/quota_nld
-%attr(0755,root,root) %{_initrddir}/quota_nld
+%{_unitdir}/quota_nld.service
 %attr(0755,root,root) %{_sbindir}/quota_nld
 %attr(0644,root,root) %{_mandir}/man8/quota_nld.8*
 %doc Changelog
@@ -215,9 +236,10 @@ fi
 
 
 %changelog
-* Tue Aug 30 2011 Petr Pisar <ppisar at redhat.com> - 1:4.00-2
+* Wed Aug 31 2011 Petr Pisar <ppisar at redhat.com> - 1:4.00-2
 - Remove unneeded cryptographic library build-time dependencies
 - Fortify build-time configuration
+- Migrate quota_nld service from sysvinit to systemd
 
 * Tue Aug 23 2011 Petr Pisar <ppisar at redhat.com> - 1:4.00-1
 - 4.00 bump
diff --git a/quota_nld.service b/quota_nld.service
new file mode 100644
index 0000000..d069003
--- /dev/null
+++ b/quota_nld.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Disk quota netlink message daemon
+After=syslog.target
+
+[Service]
+Type=forking
+EnvironmentFile=-/etc/sysconfig/quota_nld
+ExecStart=/usr/sbin/quota_nld $QUOTA_NLD_OPTS
+PIDFile=/var/run/quota_nld.pid
+
+[Install]
+WantedBy=multi-user.target


More information about the scm-commits mailing list