mirror of
https://github.com/archlinuxarm/PKGBUILDs.git
synced 2024-11-28 22:57:37 +00:00
52 lines
No EOL
1.9 KiB
Bash
Executable file
52 lines
No EOL
1.9 KiB
Bash
Executable file
# vim: set ft=sh:
|
|
run_hook ()
|
|
{
|
|
input="$(cat /proc/cmdline)"
|
|
mdconfig="/etc/mdadm.conf"
|
|
# for partitionable raid, we need to load md_mod first!
|
|
modprobe md_mod 2>/dev/null
|
|
# if no config file is present create one from command line parameters
|
|
if ! [ -e $mdconfig ]; then
|
|
#Create initial mdadm.conf
|
|
# scan all devices in /proc/partitions
|
|
echo DEVICE partitions > $mdconfig
|
|
for i in $input; do
|
|
case $i in
|
|
# raid
|
|
md=[0-9]*,/*)
|
|
device="$(/bin/replace -s,/ "$i" "=" "")"
|
|
array="$(/bin/replace -s/ "$device" "," " devices=")"
|
|
echo "ARRAY /dev/$array" >> $mdconfig
|
|
RAID_FOUND=1
|
|
;;
|
|
# partitionable raid
|
|
md=d[0-9]*,/*)
|
|
device="$(/bin/replace -s=d "$i" "md=" "md_")"
|
|
array="$(/bin/replace -s/ "$device" "," " devices=")"
|
|
echo "ARRAY /dev/$array" >> $mdconfig
|
|
RAID_FOUND=1
|
|
;;
|
|
# raid UUID
|
|
md=[0-9]*,[0-9,a-z]*)
|
|
device="$(/bin/replace -s,/ "$i" "=" "")"
|
|
array="$(/bin/replace -s/ "$device" "," " uuid=")"
|
|
echo "ARRAY /dev/$array" >> $mdconfig
|
|
RAID_FOUND=1
|
|
;;
|
|
# partitionable raid UUID
|
|
md=d[0-9]*,[0-9,a-z]*)
|
|
device="$(/bin/replace -s=d "$i" "md=" "md_")"
|
|
array="$(/bin/replace -s/ "$device" "," " uuid=")"
|
|
echo "ARRAY /dev/$array" >> $mdconfig
|
|
RAID_FOUND=1
|
|
;;
|
|
esac
|
|
done
|
|
else
|
|
RAID_FOUND=1
|
|
fi
|
|
if [ "$RAID_FOUND" = 1 ]; then
|
|
# assemble everything
|
|
/sbin/mdassemble.static
|
|
fi
|
|
} |