[preload] Introducing systemd unit (#951956)

Jaromír Cápík jcapik at fedoraproject.org
Thu Sep 19 16:44:23 UTC 2013


commit 56bf85991d660162fdad041c71b0a093228a050e
Author: Jaromir Capik <jcapik at redhat.com>
Date:   Thu Sep 19 18:44:00 2013 +0200

    Introducing systemd unit (#951956)

 preload.service |   14 ++++++++++++++
 preload.spec    |   38 ++++++++++++++++++++------------------
 2 files changed, 34 insertions(+), 18 deletions(-)
---
diff --git a/preload.service b/preload.service
new file mode 100644
index 0000000..292178f
--- /dev/null
+++ b/preload.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Adaptive readahead daemon
+After=kdm.service
+
+[Service]
+Type=forking
+ExecStart=/usr/sbin/preload --verbose 1
+Restart=always
+RestartSec=1
+Nice=19
+IOSchedulingClass=3
+
+[Install]
+WantedBy=multi-user.target
diff --git a/preload.spec b/preload.spec
index c7790b2..8a64e80 100644
--- a/preload.spec
+++ b/preload.spec
@@ -2,23 +2,25 @@
 
 Name:           preload
 Version:        0.6.4
-Release:        8%{?dist}
+Release:        9%{?dist}
 Summary:        Preload is an adaptive readahead daemon
 Group:          Applications/System
 License:        GPLv2+
 URL:            http://preload.sf.net/
 
 Source0:        http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz
+Source1:        %{name}.service
 
 Patch0:         preload-0.6-start-late.patch
 
 BuildRequires:  basesystem, glib2-devel, help2man
 Requires:       basesystem, logrotate
-Requires(post): /sbin/chkconfig
-Requires(post): /sbin/service
-Requires(preun): /sbin/chkconfig
-Requires(preun): /sbin/service
-Requires(postun): /sbin/service
+
+Requires(post):   systemd
+Requires(preun):  systemd
+Requires(postun): systemd
+BuildRequires:    systemd
+
 
 %description
 preload runs as a daemon and gathers information about processes running on
@@ -35,32 +37,29 @@ make
 
 
 %install
-make install DESTDIR=$RPM_BUILD_ROOT
+make install DESTDIR=%{buildroot}
 
-rm -rf $RPM_BUILD_ROOT%{_docdir}/*
+rm -rf %{buildroot}%{_docdir}/*
+rm -rf %{buildroot}%{_sysconfdir}/rc.d
 
+# systemd unit
+install -Dm644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service
 
 %post
-# This adds the proper /etc/rc*.d links for the script
-/sbin/chkconfig --add preload
+%systemd_post %{name}.service
 
 %preun
-if [ $1 = 0 ]; then
-        /sbin/service preload stop >/dev/null 2>&1
-        /sbin/chkconfig --del preload
-fi
+%systemd_preun %{name}.service
 
 %postun
-if [ "$1" -ge "1" ]; then
-        /sbin/service preload condrestart >/dev/null 2>&1 || :
-fi
+%systemd_postun_with_restart %{name}.service
 
 
 %files
 %doc README AUTHORS COPYING ChangeLog TODO THANKS NEWS doc/index.txt doc/proposal.txt
 %{_sbindir}/preload
 %{_datadir}/man/man8/preload.8.gz
-%{_sysconfdir}/rc.d/init.d/preload
+%{_unitdir}/%{name}.service
 %config(noreplace) %{_sysconfdir}/preload.conf
 %config(noreplace) %{_sysconfdir}/sysconfig/preload
 %config(noreplace) %{_sysconfdir}/logrotate.d/preload
@@ -70,6 +69,9 @@ fi
 
 
 %changelog
+* Thu Sep 19 2013 Jaromir Capik <jcapik at redhat.com> - 0.6.4-9
+- Introducing systemd unit (#951956)
+
 * Wed Aug 21 2013 Jaromir Capik <jcapik at redhat.com> - 0.6.4-8
 - Hardened build (#996742)
 - Spec cleaning


More information about the scm-commits mailing list