From 4d57643f9e27b9ee102cf63d18801a4d97eaafe4 Mon Sep 17 00:00:00 2001 From: Petr Písař Date: Sep 01 2011 09:20:17 +0000 Subject: Migrate quota_nld service from sysvinit to systemd --- 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 - 1:4.00-2 +* Wed Aug 31 2011 Petr Pisar - 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 - 1:4.00-1 - 4.00 bump diff --git a/quota_nld.init b/quota_nld.init deleted file mode 100644 index 1b52453..0000000 --- a/quota_nld.init +++ /dev/null @@ -1,104 +0,0 @@ -#!/bin/sh -# -# quota_nld Disk quota netlink message daemon -# -# chkconfig: - 25 75 -# description: quota_nld is a deamon that listens on netlink socket and \ -# passes disk quota warnings produced by kernel to system \ -# D-Bus or terminal user has last accessed. - -### BEGIN INIT INFO -# Provides: quota_nld -# Required-Start: $local_fs -# Should-Start: $syslog messagebus -# Should-Stop: $syslog messagebus -# Short-Description: Disk quota netlink message daemon -# Description: quota_nld is a deamon that listens on netlink socket and \ -# passes disk quota warnings produced by kernel to system \ -# D-Bus or terminal user has last accessed. -### END INIT INFO - -# Source function library. -. /etc/rc.d/init.d/functions - -exec="/usr/sbin/quota_nld" -prog="quota_nld" - -[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog - -lockfile=/var/lock/subsys/$prog - -start() { - [ "$(id -u)" -eq 0 ] || exit 4 - [ -x $exec ] || exit 5 - echo -n $"Starting $prog: " - daemon $exec $QUOTA_NLD_OPTS - retval=$? - echo - [ $retval -eq 0 ] && touch $lockfile - return $retval -} - -stop() { - [ "$(id -u)" -eq 0 ] || exit 4 - echo -n $"Stopping $prog: " - killproc $prog - retval=$? - echo - [ $retval -eq 0 ] && rm -f $lockfile - return $retval -} - -restart() { - stop - start -} - -reload() { - restart -} - -force_reload() { - restart -} - -rh_status() { - status $prog -} - -rh_status_q() { - rh_status >/dev/null 2>&1 -} - - -case "$1" in - start) - rh_status_q && exit 0 - $1 - ;; - stop) - rh_status_q || exit 0 - $1 - ;; - restart) - $1 - ;; - reload) - rh_status_q || exit 7 - $1 - ;; - force-reload) - force_reload - ;; - status) - rh_status - ;; - condrestart|try-restart) - rh_status_q || exit 0 - restart - ;; - *) - echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" - exit 2 -esac -exit $? 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