[mdadm] Use unit files with systemd. (thanks to johannbg) Add sub-package sysvinit for SysV init script. Res
Milan Broz
mbroz at fedoraproject.org
Thu Jul 7 11:43:16 UTC 2011
commit d00f53978499762254d376cb5d31c8a136a81adb
Author: Milan Broz <mbroz at redhat.com>
Date: Thu Jul 7 13:42:10 2011 +0200
Use unit files with systemd. (thanks to johannbg)
Add sub-package sysvinit for SysV init script.
Resolves: bz713573
mdadm.conf | 1 +
mdadm.spec | 75 +++++++++++++++++++++++++++++++++++--------
mdmonitor-takeover.service | 11 ++++++
mdmonitor.service | 13 +++++++
4 files changed, 86 insertions(+), 14 deletions(-)
---
diff --git a/mdadm.conf b/mdadm.conf
new file mode 100644
index 0000000..e70b363
--- /dev/null
+++ b/mdadm.conf
@@ -0,0 +1 @@
+D /var/run/mdadm 0710 root root -
diff --git a/mdadm.spec b/mdadm.spec
index 2bbcfc0..5b3ccc0 100644
--- a/mdadm.spec
+++ b/mdadm.spec
@@ -1,13 +1,16 @@
Summary: The mdadm program controls Linux md devices (software RAID arrays)
Name: mdadm
Version: 3.2.2
-Release: 2%{?dist}
+Release: 3%{?dist}
Source: http://www.kernel.org/pub/linux/utils/raid/mdadm/mdadm-%{version}.tar.bz2
Source1: mdmonitor.init
Source2: raid-check
Source3: mdadm.rules
Source4: mdadm-raid-check-sysconfig
Source5: mdadm-cron
+Source6: mdmonitor.service
+Source7: mdmonitor-takeover.service
+Source8: mdadm.conf
Patch0: mdadm-3.2.2-man.patch
Patch1: mdadm-3.2.1-version.patch
Patch2: mdadm-3.2.2-fixbuild.patch
@@ -18,10 +21,11 @@ License: GPLv2+
Group: System Environment/Base
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Obsoletes: mdctl,raidtools
-Requires(post): /sbin/service, /sbin/chkconfig
-Requires(preun): /sbin/service, /sbin/chkconfig
-Requires(postun): /sbin/service
-Requires: udev
+BuildRequires: systemd-units
+Requires(post): systemd-units systemd-sysv chkconfig coreutils
+Requires(preun): systemd-units
+Requires(postun): systemd-units coreutils
+Requires: udev initscripts
%description
The mdadm program is used to create, manage, and monitor Linux MD (software
@@ -30,6 +34,18 @@ package. However, mdadm is a single program, and it can perform
almost all functions without a configuration file, though a configuration
file can be used to help with some common tasks.
+%package sysvinit
+Group: System Environment/Base
+Summary: SysV init script for mdadm
+Requires: %{name} = %{version}-%{release}
+Requires(post): /sbin/service
+Requires(preun): /sbin/service
+Requires(postun): /sbin/service
+
+%description sysvinit
+SysV style init script for mdadm. It needs to be installed only if systemd
+is not used as the system init process.
+
%prep
%setup -q
%patch0 -p1 -b .man
@@ -51,38 +67,69 @@ install -Dp -m 644 %{SOURCE4} %{buildroot}%{_sysconfdir}/sysconfig/raid-check
install -Dp -m 644 %{SOURCE5} %{buildroot}%{_sysconfdir}/cron.d/raid-check
mkdir -p -m 700 %{buildroot}/var/run/mdadm
+# systemd
+mkdir -p %{buildroot}%{_unitdir}
+install -m644 %{SOURCE6} %{buildroot}%{_unitdir}
+install -m644 %{SOURCE7} %{buildroot}%{_unitdir}
+
+# tmpfile
+mkdir -p %{buildroot}%{_sysconfdir}/tmpfiles.d
+install -m 0644 %{SOURCE8} %{buildroot}%{_sysconfdir}/tmpfiles.d/%{name}.conf
+mkdir -p %{buildroot}%{_localstatedir}/run/
+install -d -m 0710 %{buildroot}%{_localstatedir}/run/%{name}/
+
%clean
rm -rf %{buildroot}
%post
-if [ "$1" = 1 ]; then
- /sbin/chkconfig --add mdmonitor
+if [ $1 -eq 1 ] ; then
+ /bin/systemctl enable mdmonitor.service mdmonitor-takeover.service >/dev/null 2>&1 || :
fi
%preun
-if [ "$1" = 0 ]; then
- service mdmonitor stop > /dev/null 2>&1 ||:
- /sbin/chkconfig --del mdmonitor
+if [ $1 = 0 ]; then
+ /bin/systemctl --no-reload mdmonitor.service > /dev/null 2>&1 || :
+ /bin/systemctl stop mdmonitor.service > /dev/null 2>&1 || :
fi
%postun
-if [ "$1" -ge "1" ]; then
- service mdmonitor condrestart > /dev/null 2>&1
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+if [ $1 -ge 1 ] ; then
+ /bin/systemctl try-restart mdmonitor.service >/dev/null 2>&1 || :
fi
+%triggerun -- %{name} < 3.2.2-3
+%{_bindir}/systemd-sysv-convert --save mdmonitor >/dev/null 2>&1 || :
+/bin/systemctl --no-reload enable mdmonitor.service mdmonitor-takeover.service >/dev/null 2>&1 || :
+/sbin/chkconfig --del mdmonitor >/dev/null 2>&1 || :
+/bin/systemctl try-restart mdmonitor.service >/dev/null 2>&1 || :
+
+%triggerpostun -n %{name}-sysvinit -- %{name} < 3.2.2-3
+/sbin/chkconfig --add mdmonitor >/dev/null 2>&1 || :
+
%files
%defattr(-,root,root,-)
%doc TODO ChangeLog mdadm.conf-example COPYING misc/*
/lib/udev/rules.d/*
/sbin/*
%{_sbindir}/raid-check
-%{_initrddir}/*
+%{_unitdir}/mdmonitor.service
+%{_unitdir}/mdmonitor-takeover.service
%{_mandir}/man*/md*
%config(noreplace) %{_sysconfdir}/cron.d/*
%config(noreplace) %{_sysconfdir}/sysconfig/*
-%ghost %attr(0700,root,root) %dir /var/run/mdadm
+%dir %{_localstatedir}/run/%{name}/
+%config(noreplace) %{_sysconfdir}/tmpfiles.d/%{name}.conf
+
+%files sysvinit
+%{_initrddir}/*
%changelog
+* Thu Jul 07 2011 Milan Broz <mbroz at redhat.com> - 3.2.2-3
+- Use unit files with systemd. (johannbg)
+- Add sub-package sysvinit for SysV init script.
+- Resolves: bz713573
+
* Wed Jul 06 2011 Milan Broz <mbroz at redhat.com> - 3.2.2-2
- Fix build on PPC.
- Resolves: bz719380
diff --git a/mdmonitor-takeover.service b/mdmonitor-takeover.service
new file mode 100644
index 0000000..c7bd2a5
--- /dev/null
+++ b/mdmonitor-takeover.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Software RAID Monitor Takeover
+After=syslog.target
+
+[Service]
+Type=forking
+RemainAfterExit=yes
+ExecStart=/sbin/mdmon --takeover --all
+
+[Install]
+WantedBy=sysinit.target
diff --git a/mdmonitor.service b/mdmonitor.service
new file mode 100644
index 0000000..8c92f82
--- /dev/null
+++ b/mdmonitor.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Software RAID monitoring and management
+After=syslog.target
+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
More information about the scm-commits
mailing list