diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2010-02-13 17:03:49 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2010-02-13 17:03:49 +0000 |
commit | 5e3b66ce08317c39c9689ec73ae774feae62e542 (patch) | |
tree | c7c34413b4ef3d769a49fa8b4e14b1283f57e725 /main/mdadm/mdadm-raid.initd | |
parent | 5888d93ee1d9a2c4bda4dd77b1f4c05de427ef09 (diff) | |
download | aports-5e3b66ce08317c39c9689ec73ae774feae62e542.tar.bz2 aports-5e3b66ce08317c39c9689ec73ae774feae62e542.tar.xz |
main/mdadm: fix init.d script
Diffstat (limited to 'main/mdadm/mdadm-raid.initd')
-rw-r--r-- | main/mdadm/mdadm-raid.initd | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/main/mdadm/mdadm-raid.initd b/main/mdadm/mdadm-raid.initd index ea840888..d2479737 100644 --- a/main/mdadm/mdadm-raid.initd +++ b/main/mdadm/mdadm-raid.initd @@ -1,19 +1,42 @@ #!/sbin/runscript # script to start raid devices described in /etc/mdadm.conf. +depend() { + before checkfs fsck + after modules +} start() { + [ -f /etc/mdadm.conf ] || return 0 + # start all devices that are not already started [ -f /proc/mdstat ] || modprobe -k md > /dev/null 2>&1 + local tostart= ebegin "Starting RAID devices" - mdadm -A -s -q + for i in $(awk '{print $2}' /etc/mdadm.conf); do + [ -b "$i" ] && continue + tostart="$tostart $i" + done + mdadm --assemble --scan --quiet $tostart eend $? } +is_mounted_as() { + local mnt + for mnt in $(awk "\$1 == \"$1\" {print \$2}" /proc/mounts); do + [ "$mnt" = "$2" ] && return 0 + done + return 1 +} + stop() { - # you need to make sure no device is mounted. - if [ -f /etc/mdadm.conf ] ; then - ebegin "Stopping RAID devices" - mdadm --stop -q `awk '/^ARRAY/ { print $2 }' /etc/mdadm.conf` - eend $? - fi + # stop all raid devices except anything mounted as / + [ -f /etc/mdadm.conf ] || return 0 + ebegin "Stopping RAID devices" + local tostop= + for i in $(awk '{print $2}' /etc/mdadm.conf); do + is_mounted_as $i / && continue + tostop="$tostop $i" + done + mdadm --stop --quiet $tostop + eend $? } |