#!/bin/sh
#
# post-install.sh -- execute package-specific operations after a
#                    Software Set installation
#
# Created: January 1, 2015
#

EXE_DIR=`dirname $0 2>/dev/null`

MPNT="$1"		# mount point of target system
CF="$2"			# configuration file of target

conf_src="$EXE_DIR/aboot.conf"
conf_dir="$MPNT/boot/etc"
conf_dst="$conf_dir/aboot.conf"
fstab="$MPNT/etc/fstab"

mkdir $conf_dir || exit 1

# determine rootfs device "/":
dev=""
grep -v '^[[:blank:]]*#' $fstab | tr -s ' ' '\t' | cut -f-2 | while read pair
do
	path=`echo "$pair" | cut -f2`
	if test "$path" = "/"; then
		dev=`echo "$pair" | cut -f1`
		break
	fi
done

# generate aboot.conf file while substituting rootfs device:
sed -e "s:@ROOT@:$dev:" $conf_src > $conf_dst
