From 8491dee0428b45db4cabf3ddee8bb5b9c6e18f83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Dom=C3=ADnguez?= Date: Sun, 9 Feb 2020 08:35:31 +0100 Subject: [PATCH] Replace raid-check cron job with systemd timer --- mdadm-cron | 3 --- mdadm.spec | 40 +++++++++++++++++++++++++--------------- raid-check.service | 9 +++++++++ raid-check.timer | 10 ++++++++++ 4 files changed, 44 insertions(+), 18 deletions(-) delete mode 100644 mdadm-cron create mode 100644 raid-check.service create mode 100644 raid-check.timer diff --git a/mdadm-cron b/mdadm-cron deleted file mode 100644 index 4e05d68..0000000 --- a/mdadm-cron +++ /dev/null @@ -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 - diff --git a/mdadm.spec b/mdadm.spec index 746eae1..edbd65b 100644 --- a/mdadm.spec +++ b/mdadm.spec @@ -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 - 4.1-3 +- Replace raid-check cron job with systemd timer + * Wed Jan 29 2020 Fedora Release Engineering - 4.1-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild diff --git a/raid-check.service b/raid-check.service new file mode 100644 index 0000000..e17067c --- /dev/null +++ b/raid-check.service @@ -0,0 +1,9 @@ +[Unit] +Description=RAID setup health check + +[Service] +Type=oneshot +ExecStart=/usr/sbin/raid-check + +[Install] +WantedBy=multi-user.target diff --git a/raid-check.timer b/raid-check.timer new file mode 100644 index 0000000..c33bc24 --- /dev/null +++ b/raid-check.timer @@ -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