Replace raid-check cron job with systemd timer

This commit is contained in:
Alejandro Domínguez 2020-02-09 08:35:31 +01:00
parent 798932b8b6
commit 8491dee042
4 changed files with 44 additions and 18 deletions

View File

@ -1,3 +0,0 @@
# Run system wide raid-check once a week on Sunday at 1am by default
0 1 * * Sun root /usr/sbin/raid-check

View File

@ -1,7 +1,7 @@
Name: mdadm
Version: 4.1
#define subversion rc2
Release: 2%{?subversion:.%{subversion}}%{?dist}
Release: 3%{?subversion:.%{subversion}}%{?dist}
Summary: The mdadm program controls Linux md devices (software RAID arrays)
URL: http://www.kernel.org/pub/linux/utils/raid/mdadm/
License: GPLv2+
@ -10,10 +10,11 @@ Source: http://www.kernel.org/pub/linux/utils/raid/mdadm/%{name}-%{version}
Source1: raid-check
Source2: mdadm.rules
Source3: mdadm-raid-check-sysconfig
Source4: mdadm-cron
Source5: mdmonitor.service
Source6: mdadm.conf
Source7: mdadm_event.conf
Source4: mdmonitor.service
Source5: mdadm.conf
Source6: mdadm_event.conf
Source7: raid-check.timer
Source8: raid-check.service
# Build without -Werror. From Debian.
Patch00: https://sources.debian.org/data/main/m/mdadm/4.1-2/debian/patches/debian-no-Werror.diff#/mdadm-4.1-no-Werror.patch
@ -22,7 +23,7 @@ Patch00: https://sources.debian.org/data/main/m/mdadm/4.1-2/debian/patches/d
Patch97: mdadm-3.3-udev.patch
Patch98: mdadm-2.5.2-static.patch
BuildRequires: systemd binutils-devel gcc
BuildRequires: systemd-rpm-macros binutils-devel gcc
Requires: libreport-filesystem
Requires(post): systemd coreutils
Requires(preun): systemd
@ -42,33 +43,40 @@ file can be used to help with some common tasks.
make %{?_smp_mflags} CXFLAGS="$RPM_OPT_FLAGS" LDFLAGS="$RPM_LD_FLAGS" SYSCONFDIR="%{_sysconfdir}" mdadm mdmon
%install
make DESTDIR=%{buildroot} MANDIR=%{_mandir} BINDIR=%{_sbindir} SYSTEMD_DIR=%{_unitdir} install install-systemd
make DESTDIR=%{buildroot} MANDIR=%{_mandir} BINDIR=%{_sbindir} SYSTEMD_DIR=%{_unitdir} UDEVDIR=%{_udevrulesdir} install install-systemd
install -Dp -m 755 %{SOURCE1} %{buildroot}%{_sbindir}/raid-check
install -Dp -m 644 %{SOURCE2} %{buildroot}%{_udevrulesdir}/65-md-incremental.rules
install -Dp -m 644 %{SOURCE3} %{buildroot}%{_sysconfdir}/sysconfig/raid-check
install -Dp -m 644 %{SOURCE4} %{buildroot}%{_sysconfdir}/cron.d/raid-check
mkdir -p -m 710 %{buildroot}/run/mdadm
# systemd
mkdir -p %{buildroot}%{_unitdir}
install -m644 %{SOURCE5} %{buildroot}%{_unitdir}
install -m644 %{SOURCE4} %{buildroot}%{_unitdir}
install -m644 %{SOURCE7} %{buildroot}%{_unitdir}
install -m644 %{SOURCE8} %{buildroot}%{_unitdir}
# tmpfile
mkdir -p %{buildroot}%{_tmpfilesdir}
install -m 0644 %{SOURCE6} %{buildroot}%{_tmpfilesdir}/%{name}.conf
install -m 0644 %{SOURCE5} %{buildroot}%{_tmpfilesdir}/%{name}.conf
mkdir -p %{buildroot}%{_localstatedir}/run/
install -d -m 0710 %{buildroot}/run/%{name}/
# abrt
mkdir -p %{buildroot}/etc/libreport/events.d
install -m644 %{SOURCE7} %{buildroot}/etc/libreport/events.d
install -m644 %{SOURCE6} %{buildroot}/etc/libreport/events.d
%post
%systemd_post mdmonitor.service
/usr/bin/systemctl disable mdmonitor-takeover.service >/dev/null 2>&1 || :
%systemd_post mdmonitor.service raid-check.{service,timer}
%{_bindir}/systemctl disable mdmonitor-takeover.service >/dev/null 2>&1 || :
# If there is any cron daemon configured, enable the systemd timer to avoid
# breaking the configuration silently when upgrading from 4.1-rc2.0.2 or
# earlier versions
%triggerin -- mdadm < 4.1-rc2.0.2
[ -e %{_sysconfdir}/crontab -o -e %{_sysconfdir}/anacrontab -o -e %{_sysconfdir}/fcrontab ] && %{_bindir}/systemctl enable raid-check.timer &>/dev/null || :
%preun
%systemd_preun mdmonitor.service
%systemd_preun mdmonitor.service raid-check.timer
%postun
%systemd_postun_with_restart mdmonitor.service
@ -81,13 +89,15 @@ install -m644 %{SOURCE7} %{buildroot}/etc/libreport/events.d
%{_unitdir}/*
%{_mandir}/man*/md*
/usr/lib/systemd/system-shutdown/*
%config(noreplace) %{_sysconfdir}/cron.d/*
%config(noreplace) %{_sysconfdir}/sysconfig/*
%dir /run/%{name}/
%config(noreplace) %{_tmpfilesdir}/%{name}.conf
/etc/libreport/events.d/*
%changelog
* Fri Feb 09 2020 Alejandro Domínguez Muñoz <adomu@net-c.com> - 4.1-3
- Replace raid-check cron job with systemd timer
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 4.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

9
raid-check.service Normal file
View File

@ -0,0 +1,9 @@
[Unit]
Description=RAID setup health check
[Service]
Type=oneshot
ExecStart=/usr/sbin/raid-check
[Install]
WantedBy=multi-user.target

10
raid-check.timer Normal file
View File

@ -0,0 +1,10 @@
[Unit]
Description=Weekly RAID setup health check
[Timer]
OnCalendar=Sun *-*-* 01:00:00
Persistent=true
AccuracySec=24h
[Install]
WantedBy=timers.target