Package: mdadm Version: 4.2+20230508-7 Severity: normal Tags: patch Dear Daniel,
As was discussed in #1037496, the removal of cron scripts from mdadm means that no mdamd housekeeping is performed when systemd timers are not available. I attach a patch which restores the cron scripts in mdadm, but protects them with a test for running systemd. This should mean that housekeeping tasks are performed an all systems, but that there is no duplication when systemd timers are available. I hope this is an acceptable compromise and I look forward to your comments. With best wishes Mark
>From 1f4b2370e6ffaab0b6352b893f268e0fa39df55b Mon Sep 17 00:00:00 2001 From: Mark Hindley <m...@hindley.org.uk> Date: Tue, 14 Nov 2023 19:52:52 +0000 Subject: [PATCH] Restore cron fragments, but prefer systemd timers. --- debian/mdadm.cron.d | 12 ++++++++++++ debian/mdadm.cron.daily | 23 +++++++++++++++++++++++ debian/mdadm.maintscript | 2 -- debian/mdadm.postinst | 3 ++- 4 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 debian/mdadm.cron.d create mode 100644 debian/mdadm.cron.daily diff --git a/debian/mdadm.cron.d b/debian/mdadm.cron.d new file mode 100644 index 0000000..63f186d --- /dev/null +++ b/debian/mdadm.cron.d @@ -0,0 +1,12 @@ +# +# cron.d/mdadm -- schedules periodic redundancy checks of MD devices +# +# Copyright © martin f. krafft <madd...@madduck.net> +# distributed under the terms of the Artistic Licence 2.0 +# + +# By default, run at 00:57 on every Sunday, but do nothing unless the day of +# the month is less than or equal to 7. Thus, only run on the first Sunday of +# each month. crontab(5) sucks, unfortunately, in this regard; therefore this +# hack (see #380425). +57 0 * * 0 root if [ -x /usr/share/mdadm/checkarray ] && [ ! -d /run/systemd/system ] && [ $(date +\%d) -le 7 ]; then /usr/share/mdadm/checkarray --cron --all --idle --quiet; fi diff --git a/debian/mdadm.cron.daily b/debian/mdadm.cron.daily new file mode 100644 index 0000000..8d1bfeb --- /dev/null +++ b/debian/mdadm.cron.daily @@ -0,0 +1,23 @@ +#!/bin/sh +# +# cron.daily/mdadm -- daily check that MD devices are functional +# +# Copyright © 2008 Paul Slootman <p...@debian.org> +# distributed under the terms of the Artistic Licence 2.0 + +# As recommended by the manpage, run +# mdadm --monitor --scan --oneshot +# every day to ensure that any degraded MD devices don't go unnoticed. +# Email will go to the address specified in /etc/mdadm/mdadm.conf . +# +set -eu + +MDADM=/sbin/mdadm +[ -x $MDADM ] || exit 0 # package may be removed but not purged + +[ -d /run/systemd/system ] || exit 0 # Defer to systemd timers if possible + +[ -e /etc/default/mdadm ] && . /etc/default/mdadm +[ $AUTOSCAN = false ] && exit 0 + +exec $MDADM --monitor --scan --oneshot diff --git a/debian/mdadm.maintscript b/debian/mdadm.maintscript index 17b5e28..1298978 100644 --- a/debian/mdadm.maintscript +++ b/debian/mdadm.maintscript @@ -1,4 +1,2 @@ -rm_conffile /etc/cron.d/mdadm 4.2+20230227-1~ -rm_conffile /etc/cron.daily/mdadm 4.2+20230227-1~ rm_conffile /etc/init.d/mdadm 4.2+20230227-1~ rm_conffile /etc/init.d/mdadm-waitidle 4.2+20230227-1~ diff --git a/debian/mdadm.postinst b/debian/mdadm.postinst index c8a3420..021912a 100755 --- a/debian/mdadm.postinst +++ b/debian/mdadm.postinst @@ -76,7 +76,8 @@ AUTOCHECK=$AUTOCHECK # AUTOSCAN: # should mdadm check once a day for degraded arrays? See -# /lib/systemd/system/mdmonitor-oneshot.service +# /lib/systemd/system/mdmonitor-oneshot.service and +# /etc/cron.daily/mdadm. AUTOSCAN=$AUTOSCAN # START_DAEMON: -- 2.39.2