#! /bin/sh

#
# /sbin/installkernelcmdline.iSeries  - written by streeter@redhat.com
#
# installcmdline a|b|c|prep [<kernel commandline>]

SIDE=`echo $1|tr a-z A-Z`
if [ PREP = $SIDE ]; then
    SIDE=C
fi

shift

COMMANDLINE="$*"

if [ -n "$SIDE" ]; then
    if [ -z "$COMMANDLINE" ]; then
	tmppart=`mount | sed -n -e 's/^\([/[:alnum:]]\+\) on \/ type .*$/\1/p'`
	if [ -n "$tmppart" ]; then
	    COMMANDLINE="root=$tmppart"
	fi
    fi
    if [ -z "$COMMANDLINE" ]; then
	echo "Cannot find a root partition"
    else
	dd if=/dev/zero of=/proc/iSeries/mf/$SIDE/cmdline bs=256 count=1
	printf "$COMMANDLINE \0000" > /proc/iSeries/mf/$SIDE/cmdline
	exit
    fi
fi

echo "Usage:"
echo "	installcmdline a|b|c|prep [<kernel commandline>]"

exit -1
