From e70214c8532ae35999ba5c363d938b8974313b1c Mon Sep 17 00:00:00 2001 From: Nicolas Pierron Date: Tue, 29 Dec 2009 10:04:54 +0000 Subject: [PATCH] Remove loop of new-device messages. Add a shell script to watch new devices. svn path=/nixos/trunk/; revision=19142 --- modules/tasks/swraid.nix | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/modules/tasks/swraid.nix b/modules/tasks/swraid.nix index b9465822601..c51664d7e32 100644 --- a/modules/tasks/swraid.nix +++ b/modules/tasks/swraid.nix @@ -5,15 +5,28 @@ let tempConf = "/var/run/mdadm.conf"; + logFile = "/var/log/mdadmEvents.log"; modprobe = config.system.sbin.modprobe; inherit (pkgs) mdadm; + mdadmEventHandler = pkgs.writeScript "mdadmEventHandler.sh" '' + #!/bin/sh + + echo "$@" >> ${logFile} + case $1 in + (NewArray) + initctl emit -n new-devices + ;; + (*) ;; + esac + ''; + in { jobs.swraid = - { startOn = "started udev or new-devices"; + { startOn = [ "startup" "new-devices" ]; script = '' @@ -30,11 +43,16 @@ in # Activate each device found. ${mdadm}/sbin/mdadm --assemble -c ${tempConf} --scan - - initctl emit -n new-devices ''; - task = true; + task = true; }; + jobs.swraidEvents = { + name = "swraid-events"; + description = "Watch mdadm events."; + startOn = [ "startup" ]; + exec = "${mdadm}/sbin/mdadm --monitor --scan --program ${mdadmEventHandler}"; + }; + }