#!/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 ;; crypto-lvm) # Register this RAID as a PV for initial_auto_raid_crypto_lvm rm -rf filesystem mountpoint use_filesystem options format echo crypto >method echo "/dev/md$raidnum" >>/var/lib/partman/initial_auto_raid_crypto_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 \