# sysvinit-inittab - postinst
set -e
# run this on host and on target
if [ "115200;ttyS0 115200;ttyO0 115200;ttyAMA0" = "" ]; then
       exit 0
fi

if [ -n "$D" ]; then
    $INTERCEPT_DIR/postinst_intercept delay_to_first_boot sysvinit-inittab mlprefix=
    exit 0
fi
# run this on the target
if [ -e /proc/consoles ]; then
	tmp="115200;ttyS0 115200;ttyO0 115200;ttyAMA0"
	for i in $tmp
	do
		j=`echo ${i} | sed -e s/^.*\;//g -e s/\:.*//g`
		k=`echo ${i} | sed s/^.*\://g`
		if [ -z "`grep ${j} /proc/consoles`" ]; then
			if [ -z "${k}" ] || [ -z "`grep ${k} /proc/consoles`" ] || [ ! -e /dev/${j} ]; then
				sed -i -e /^.*${j}\ /d -e /^.*${j}$/d /etc/inittab
			fi
		fi
	done
	kill -HUP 1
else
	exit 1
fi