#!/boot/rc

##	set up ramfs as a rootlike fs

hostdir=`{cat '#c/hostowner'}
if (! ~ $hostdir ?*){
	echo please set hostowner
	exit no.hostowner
}
usercheck=`{cat /dev/user}
if(~ $usercheck '')
	echo danger no user set

cd /
echo -n 'ramfs -S ramboot...'
ramfs -S ramboot
mount -c /srv/ramboot /root
bind -ac /root /
echo -n 'tar xf /boot/skel.tar...'
tar xf /boot/skel.tar
if (test -d /root/mnt)
	bind -ac /root/mnt /mnt
mount -b /srv/factotum /mnt
bind -ac /root/bin /bin

##	get tgzfs if chosen and load into the ramdisk

if(~ $tgzfs *.tgz){
	dossrv
	if(~ $fatpath '')
		fatpath=`{ls /dev/sd*/9fat}
	if(! test -d /x)
		mkdir /root/x
	mount /srv/dos /x $fatpath
	if(test -e /x/$tgzfs){
		echo -n tar xzf $tgzfs^...
		tar xzf /x/$tgzfs
	}
	if not
		echo 'tgz not found continuing with only /boot'
}

##	if we aren't bootes we need to have a $home

if(! ~ $usercheck bootes){
	echo 'copying bootes skeleton to '$usercheck
	mkdir /root/usr/$usercheck
	mkdir /root/usr/$usercheck/lib
	mkdir /root/usr/$usercheck/tmp
	mkdir /root/usr/$usercheck/bin
	mkdir /root/usr/$usercheck/bin/rc
	mkdir /root/usr/$usercheck/bin/$cputype
	cp /usr/bootes/lib/profile /root/usr/$usercheck/lib/profile
}

bind -c /usr/$usercheck/tmp /tmp
echo 'partial root built'

exit ''
