1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
#!/bin/sh
# Set the filesystems for the newly created preseeded RAID config
. /lib/partman/lib/base.sh
fix_raid_fs() {
raidnum=$1
fstype=$2
mountpoint=$3
dev="/var/lib/partman/devices/=dev=md$raidnum"
if [ ! -d $dev ]; then
logger -t partman-auto-raid "Error: directory for /dev/md$raidnum not found"
db_set partman-auto-raid/error false
db_input critical partman-auto-raid/error
db_go
exit 1
fi
cd $dev
id=$(ls -d 0-*)
if [ -z $id ]; then
logger -t partman-auto-raid "Error: incorrect directory for /dev/md$raidnum"
db_set partman-auto-raid/error false
db_input critical partman-auto-raid/error
db_go
exit 1
fi
cd $id
case "$fstype" in
swap)
rm -rf filesystem mountpoint use_filesystem options
echo swap >method
;;
lvm)
# Register this RAID as a PV for initial_auto_raid_lvm
rm -rf filesystem mountpoint use_filesystem options format
echo lvm >method
echo "/dev/md$raidnum" >>/var/lib/partman/initial_auto_raid_pvs
;;
*)
echo "$fstype" >filesystem
echo "$mountpoint" >mountpoint
echo format >method
touch use_filesystem
mkdir options
;;
esac
touch format
touch formatable
update_partition $dev $id
}
# Only run if we have succesfully done the initial_auto_raid stuff
if [ ! -f /var/lib/partman/do_initial_auto_raid_fs ]; then
exit 0
fi
rm /var/lib/partman/do_initial_auto_raid_fs
rm -f /var/lib/partman/initial_auto_raid_pvs
# Check we have the stashed value of the first RAID dev we created
db_get partman-auto-raid/raidnum
if [ -z "$RET" ]; then
logger -t partman-auto-raid "Error: cannot determine device number for RAID device"
db_set partman-auto-raid/error false
db_input critical partman-auto-raid/error
db_go
exit 1
fi
raidnum=$RET
# We've already checked that there is a recipe
db_get partman-auto-raid/recipe
recipes=$RET
# Try to act on each recipe we were given
while [ -n "$recipes" ]; do
tmp=$recipes
recipes=$(echo $tmp | sed -e 's/^[^.]*\.\(.*\)$/\1/');
recipe=$(echo $tmp | sed -e 's/^\([^.]*\)\..*$/\1/');
if [ "$recipe" = "$recipes" ]; then
recipes=''
fi
# Do the recipe!
echo $recipe >/tmp/partman-auto-raid-fs-recipe
read raidtype devcount sparecount fstype mountpoint devs \
</tmp/partman-auto-raid-fs-recipe
fix_raid_fs $raidnum $fstype $mountpoint
raidnum=$(($raidnum + 1))
done
|