#!/sbin/sh
# Usage:	install_cd0 <boot image absolute path>
# parameters:	$1 = boot image directory (Ex: /export2/s26_sparc)

BOOTIMAGE=$1
BOOT=${BOOTIMAGE}/Solaris_*/Tools/Boot
CD0=${BOOTIMAGE}/.cd0

if [ `/usr/ucb/whoami` != "root" ]; then 
	echo "Must be root."
	exit 1
fi
if [ ! "$BOOTIMAGE" -o "$1" = '-h' -o "$BOOTIMAGE" = '-help' ]; then
	echo "Usage: install_cd0 [Solaris boot image absolute path]."
	exit 1
fi

if [ ! -d "`ls -d $BOOTIMAGE/Solaris_*`" ]; then
        echo "There is no Solaris directory in ${BOOTIMAGE}."
        exit 1
fi

if [ -d "$CD0" ]; then
	echo "Uninstalling previous version of CD0 ..."
	rm -rf $CD0
fi

echo "Installing CD0 ..."

mkdir -p $CD0

cp  rcS  		$BOOT/sbin/rcS
cp  startup		$BOOT/sbin/startup
# cp  openwin-init	$BOOT/usr/sbin/install.d/openwin-init
# cp  Xdefaults		$BOOT/usr/sbin/install.d/Xdefaults
# cp  Xinitrc		$BOOT/usr/sbin/install.d/Xinitrc
cp -r ../cd0		$CD0/bin
cp -r ../disk0 		$CD0/bin

echo "Installation complete."

