#!/bin/rc
# Plan9 script to kick off installation process
CDPATH=0
if (~ $0 */install/Plan9.rc) {
	CDPATH=`{ echo $0 | sed 's/\/install\/Plan9.rc$//'}
}
if not {
	echo 'usage: <cdpath>/install/Plan9.rc <inferno root>'
	exit 1
}
EMUPATH=Plan9/$cputype/bin
uflag=()
if (! ~ $#* 0 && ~ $1 -u) {
	uflag=-u
	shift
}
if (~ $#* 1)
	;
if not {
	echo 'usage: Plan9.rc <inferno root>'
	exit 1
}
if (test -d $1)
	;
if not {
	echo 'inferno root directory not found'
	exit 1
}
@{
rfork nes
$CDPATH/$EMUPATH/emu -c1 -G -r$CDPATH /dis/install/install.dis $uflag -r $1 -s -p Plan9
}
if (test -e $CDPATH/LICENCE)
	cp $CDPATH/LICENCE $1/LICENCE
if (test -e $1/$EMUPATH/emu.new)
	mv $1/$EMUPATH/emu.new $1/$EMUPATH/emu
if (! test -e $1/$EMUPATH/emu)
	exit 1
exit 0
