[packages/mdadm] - add systemd service - rel 2

baggins baggins at pld-linux.org
Sat Feb 25 12:07:01 CET 2017


commit 79d5f6a24d8cd7c6f32b45616c0bf7ab1978fc4f
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Sat Feb 25 12:06:47 2017 +0100

    - add systemd service
    - rel 2

 mdadm.service | 12 ++++++++++++
 mdadm.spec    | 22 +++++++++++++++++++---
 2 files changed, 31 insertions(+), 3 deletions(-)
---
diff --git a/mdadm.spec b/mdadm.spec
index 38aeab0..19d64ad 100644
--- a/mdadm.spec
+++ b/mdadm.spec
@@ -8,7 +8,7 @@ Summary:	Tool for creating and maintaining software RAID devices
 Summary(pl.UTF-8):	Narzędzie do tworzenia i obsługi programowych macierzy RAID
 Name:		mdadm
 Version:	4.0
-Release:	1
+Release:	2
 License:	GPL v2+
 Group:		Base
 Source0:	https://www.kernel.org/pub/linux/utils/raid/mdadm/%{name}-%{version}.tar.xz
@@ -17,6 +17,7 @@ Source1:	%{name}.init
 Source2:	%{name}.sysconfig
 Source3:	%{name}.cron
 Source4:	%{name}-checkarray
+Source5:	%{name}.service
 URL:		https://www.kernel.org/pub/linux/utils/raid/mdadm/
 BuildRequires:	groff
 BuildRequires:	rpmbuild(macros) >= 1.213
@@ -27,12 +28,13 @@ BuildRequires:	dietlibc-static
 BuildRequires:	glibc-static
 	%endif
 %endif
-BuildRequires:	rpmbuild(macros) >= 1.268
+BuildRequires:	rpmbuild(macros) >= 1.671
 BuildRequires:	tar >= 1:1.22
 BuildRequires:	xz
 Requires(post,preun):	/sbin/chkconfig
 Requires:	/sbin/chkconfig
 Requires:	rc-scripts >= 0.4.2.4-2
+Requires:	systemd-units >= 38
 Suggests:	crondaemon
 %{!?with_initrd:Obsoletes:	mdadm-initrd < %{version}-%{release}}
 Obsoletes:	mdctl
@@ -115,7 +117,8 @@ mv mdassemble regular-mdassemble
 
 %install
 rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT{%{_sbindir},%{_mandir}/man{5,8},/etc/{rc.d/init.d,sysconfig,cron.d}}
+install -d $RPM_BUILD_ROOT{%{_sbindir},%{_mandir}/man{5,8}} \
+	$RPM_BUILD_ROOT{/etc/{rc.d/init.d,sysconfig,cron.d},%{systemdunitdir}}
 
 %if %{with initrd}
 install -d $RPM_BUILD_ROOT%{_libdir}/initrd
@@ -140,18 +143,30 @@ cp -p %{SOURCE2} $RPM_BUILD_ROOT/etc/sysconfig/%{name}
 cp -p %{SOURCE3} $RPM_BUILD_ROOT/etc/cron.d/mdadm-checkarray
 install -p %{SOURCE4} $RPM_BUILD_ROOT%{_sbindir}/mdadm-checkarray
 
+# Install systemd unit
+install -p %{SOURCE5} $RPM_BUILD_ROOT%{systemdunitdir}/mdadm.service
+
 %clean
 rm -rf $RPM_BUILD_ROOT
 
 %post
 /sbin/chkconfig --add %{name}
 %service mdadm restart "RAID monitoring"
+%systemd_post mdadm.service
 
 %preun
 if [ "$1" = "0" ]; then
 	%service mdadm stop
 	/sbin/chkconfig --del mdadm
 fi
+%systemd_preun mdadm.service
+
+%postun
+/sbin/ldconfig
+%systemd_reload
+
+%triggerpostun -- %{name} < 4.0-2
+%systemd_trigger mdadm.service
 
 %files
 %defattr(644,root,root,755)
@@ -160,6 +175,7 @@ fi
 %attr(755,root,root) %{_sbindir}/mdadm-checkarray
 %attr(755,root,root) %{_sbindir}/mdassemble
 %attr(755,root,root) %{_sbindir}/mdctl
+%{systemdunitdir}/mdadm.service
 %attr(640,root,root) %config(noreplace,missingok) %verify(not md5 mtime size) %{_sysconfdir}/mdadm.conf
 %{_mandir}/man5/mdadm.conf.5*
 %{_mandir}/man8/mdadm.8*
diff --git a/mdadm.service b/mdadm.service
new file mode 100644
index 0000000..123ae8a
--- /dev/null
+++ b/mdadm.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Software RAID monitoring and management
+ConditionPathExists=/etc/mdadm.conf
+
+[Service]
+Type=forking
+PIDFile=/var/run/mdadm/mdadm.pid
+EnvironmentFile=-/etc/sysconfig/mdmonitor
+ExecStart=/sbin/mdadm --monitor --scan -f --pid-file=/var/run/mdadm/mdadm.pid
+
+[Install]
+WantedBy=multi-user.target
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/mdadm.git/commitdiff/79d5f6a24d8cd7c6f32b45616c0bf7ab1978fc4f



More information about the pld-cvs-commit mailing list