Use unit files with systemd. (thanks to johannbg)

Add sub-package sysvinit for SysV init script.
Resolves: bz713573
This commit is contained in:
Milan Broz 2011-07-07 13:42:10 +02:00
parent b979607a1c
commit d00f539784
4 changed files with 86 additions and 14 deletions

1
mdadm.conf Normal file
View File

@ -0,0 +1 @@
D /var/run/mdadm 0710 root root -

View File

@ -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@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@redhat.com> - 3.2.2-2
- Fix build on PPC.
- Resolves: bz719380

View File

@ -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

13
mdmonitor.service Normal file
View File

@ -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