SHA256
1
0
forked from pool/mdadm
mdadm/mdmonitor
Neil Brown 702c57405a - mdmonitor
run "mdadm --monitor" from systemd instead of init.d
  sciprt (bnc#849523)
- remove mdadmd due to above.
- udev-rules-try-mdadm-I-on-change-events.patch
  (bnc#851993)
- policy-NULL-path-isn-t-really-acceptable-use-the-dev.patch
- DDF-really-ignore-DDF-metadata-on-partitions.patch
- Assemble-avoid-infinite-loop-when-auto-assembling-pa.patch
- DDF-fix-detection-of-failed-devices-during-assembly.patch
- Grow-fix-problems-with-prematurely-aborting-of-resha.patch
- IMSM-don-t-crash-when-creating-an-array-with-missing.patch
- mdmon-don-t-complain-about-notifying-parent-when-the.patch
- systemd-mdmon-set-IMSM_NO_PLATFORM-1.patch
- mdmon-.service-remove-over-ride-of-Standard-IO.patch
  Various upstream bug fixes.

OBS-URL: https://build.opensuse.org/package/show/Base:System/mdadm?expand=0&rev=101
2014-01-22 04:59:00 +00:00

118 lines
3.8 KiB
Plaintext

From 61c094715836e76b66d7a69adcb6769127b5b77d Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.de>
Date: Wed, 11 Dec 2013 10:47:54 +1100
Subject: [PATCH] Add mdmonitor.service systemd unit file.
References: bnc#849523
This systemd unit file runs mdadm in --monitor mode.
It is started by a SYSTEMD_WANTS signal from udev whenever
an md array is started that would benefit from mdadm --monitor.
Commandline arguments can be provided by a script
/usr/lib/systemd/scripts/mdadm_env.sh
which should write an
MDADM_MONITOR_ARGS=....
line to /run/sysconfig/mdadm
A script to extra args from SUSE's /etc/sysconfig/mdadm file
is provided.
If no mdadm_env.sh is provided, then args are "--scan" which
requires "mail" or "program" to be set in /etc/mdadm.conf.
I believe this is suitable for Fedora.
Signed-off-by: NeilBrown <neilb@suse.de>
---
Makefile | 2 ++
systemd/SUSE-mdadm_env.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++
systemd/mdmonitor.service | 16 ++++++++++++++++
udev-md-raid-arrays.rules | 2 ++
4 files changed, 65 insertions(+)
--- mdadm-3.3.orig/Makefile
+++ mdadm-3.3/Makefile
@@ -285,6 +285,8 @@ install-udev: udev-md-raid-arrays.rules
install-systemd: systemd/mdmon@.service
$(INSTALL) -D -m 644 systemd/mdmon@.service $(DESTDIR)$(SYSTEMD_DIR)/mdmon@.service
+ $(INSTALL) -D -m 644 systemd/mdmonitor.service $(DESTDIR)$(SYSTEMD_DIR)/mdmonitor.service
+ [ -f /etc/SuSE-release -o -n "$(SUSE)" ] && $(INSTALL) -D -m 755 systemd/SUSE-mdadm_env.sh $(DESTDIR)$(SYSTEMD_DIR)/../scripts/mdadm_env.sh || true
uninstall:
rm -f $(DESTDIR)$(MAN8DIR)/mdadm.8 $(DESTDIR)$(MAN8DIR)/mdmon.8 $(DESTDIR)$(MAN4DIR)/md.4 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5 $(DESTDIR)$(BINDIR)/mdadm
--- /dev/null
+++ mdadm-3.3/systemd/SUSE-mdadm_env.sh
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+# extract configuration from /etc/sysconfig/mdadm and write
+# environment to /run/sysconfig/mdadm to be used by
+# systemd unit files.
+
+MDADM_SCAN="yes"
+
+# Following adapted from /etc/init.d/mdadmd on openSUSE
+
+mdadmd_CONFIG=/etc/sysconfig/mdadm
+if test -r $mdadmd_CONFIG; then
+ . $mdadmd_CONFIG
+fi
+
+if [ x$MDADM_DELAY != x"" ]; then
+ MDADM_DELAY="-d "$MDADM_DELAY;
+fi
+
+if [ x$MDADM_MAIL != x"" ]; then
+ MDADM_MAIL="-m \"$MDADM_MAIL\""
+fi
+
+if [ x$MDADM_PROGRAM != x"" ]; then
+ MDADM_PROGRAM="-p \"$MDADM_PROGRAM\""
+fi
+
+if [ x$MDADM_SCAN = x"yes" ]; then
+ MDADM_SCAN="--scan"
+else
+ MDADM_SCAN=""
+fi
+
+if [ x$MDADM_SEND_MAIL_ON_START = x"yes" ]; then
+ MDADM_SEND_MAIL="-t"
+else
+ MDADM_SEND_MAIL=""
+fi
+
+if [ x$MDADM_CONFIG != x"" ]; then
+ MDADM_CONFIG="-c \"$MDADM_CONFIG\""
+fi
+
+mkdir -p /run/sysconfig
+echo "MDADM_MONITOR_ARGS=$MDADM_RAIDDEVICES $MDADM_DELAY $MDADM_MAIL $MDADM_PROGRAM $MDADM_SCAN $MDADM_SEND_MAIL $MDADM_CONFIG" > /run/sysconfig/mdadm
--- /dev/null
+++ mdadm-3.3/systemd/mdmonitor.service
@@ -0,0 +1,16 @@
+# This file is part of mdadm.
+#
+# mdadm is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+[Unit]
+Description=MD array monitor
+DefaultDependencies=no
+
+[Service]
+Environment= MDADM_MONITOR_ARGS=--scan
+EnvironmentFile=-/run/sysconfig/mdadm
+ExecStartPre=-/usr/lib/systemd/scripts/mdadm_env.sh
+ExecStart=/sbin/mdadm --monitor $MDADM_MONITOR_ARGS
--- mdadm-3.3.orig/udev-md-raid-arrays.rules
+++ mdadm-3.3/udev-md-raid-arrays.rules
@@ -32,4 +32,6 @@ OPTIONS+="watch"
ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"
ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}"
+ENV{MD_LEVEL}=="raid[1-9]*", ENV{SYSTEMD_WANTS}+="mdmonitor.service"
+
LABEL="md_end"