diff options
author | Michał Masłowski <mtjm@mtjm.eu> | 2012-05-06 11:43:14 +0200 |
---|---|---|
committer | Michał Masłowski <mtjm@mtjm.eu> | 2012-05-06 11:43:14 +0200 |
commit | 601a559448eb957ac98aca7a6e03de59e45fff91 (patch) | |
tree | 13fc71216622c3d764aa611b6a54e1918f21c496 /core/mdadm/mdadm_hook | |
parent | c96a7351e1f295c1e311860dec19ac7b506b0c5c (diff) | |
parent | f37e773fe397778858ea8d51601554863c252536 (diff) |
Merge branch 'master' of ssh://parabolagnulinux.org:1863/home/parabola/abslibre-pre-mips64el
Conflicts:
community/rtorrent/PKGBUILD
core/libcap/PKGBUILD
extra/samba/PKGBUILD
extra/systemd/PKGBUILD
extra/usbmuxd/PKGBUILD
testing/glib2/PKGBUILD
Diffstat (limited to 'core/mdadm/mdadm_hook')
-rwxr-xr-x | core/mdadm/mdadm_hook | 65 |
1 files changed, 35 insertions, 30 deletions
diff --git a/core/mdadm/mdadm_hook b/core/mdadm/mdadm_hook index 7b2dc1ad1..787be5d0c 100755 --- a/core/mdadm/mdadm_hook +++ b/core/mdadm/mdadm_hook @@ -1,44 +1,49 @@ -# vim: set ft=sh: -run_hook () -{ - input="$(cat /proc/cmdline)" - mdconfig="/etc/mdadm.conf" +#!/usr/bin/ash + +run_hook() { + local i= mdconfig=/etc/mdadm.conf + # for partitionable raid, we need to load md_mod first! modprobe md_mod 2>/dev/null - # If md is specified on commandline, create config file from those parameters. - if [ "$(echo $input | grep "md=")" ]; then - #Create initial mdadm.conf - # scan all devices in /proc/partitions - echo DEVICE partitions > $mdconfig - for i in $input; do + + if [ -n "$md" ]; then + echo 'DEVICE partitions' >"$mdconfig" + for i in $(cat /proc/cmdline); do case $i in - # raid + # raid md=[0-9]*,/*) - device="$(echo "$i" | sed -e 's|,/.*||g' -e 's|=||g')" - array="$(echo $i | cut -d, -f2-)" - echo "ARRAY /dev/$device devices=$array" >> $mdconfig + device=${i%%,*} + device=${device/=/} + array=${i#*,} + echo "ARRAY /dev/$device devices=$array" ;; # partitionable raid md=d[0-9]*,/*) - device="$(echo "$i" | sed -e 's|,/.*||g' -e 's|=|_|g')" - array="$(echo $i | cut -d, -f2-)" - echo "ARRAY /dev/$device devices=$array" >> $mdconfig + device=${i%%,*} + device=${device/=/_} + array=${i#*,} + echo "ARRAY /dev/$device devices=$array" ;; - # raid UUID - md=[0-9]*,[0-9,a-z]*) - device="$(echo "$i" | sed -e 's|,.*||g' -e 's|=||g')" - array="$(echo $i | cut -d, -f2-)" - echo "ARRAY /dev/$device UUID=$array" >> $mdconfig + # raid UUID + md=[0-9]*,[0-9,a-fA-F]*) + device=${i%%,*} + device=${device/=/} + array=${i#*,} + echo "ARRAY /dev/$device UUID=$array" ;; # partitionable raid UUID - md=d[0-9]*,[0-9,a-z]*) - device="$(echo "$i" | sed -e 's|,.*||g' -e 's|=|_|g')" - array="$(echo $i | cut -d, -f2-)" - echo "ARRAY /dev/$device UUID=$array" >> $mdconfig + md=d[0-9]*,[0-9,a-fA-F]*) + device=${i%%,*} + device=${device/=/_} + array=${i#*,} + echo "ARRAY /dev/$device UUID=$array" ;; - esac - done + esac + done >>"$mdconfig" fi + # assemble everything - [ -e $mdconfig ] && /sbin/mdassemble + [ -s "$mdconfig" ] && /sbin/mdassemble } + +# vim: set ft=sh ts=4 sw=4 et: |