code: 9ferno

ref: b39057dffedac61fd6c028908a9aaadf4426b446
dir: /dis/init/

View raw version
# boot initialization here
# sh -n /dis/init

load std

mount -a { mntgen } /n
mount -a { mntgen } /mnt

# usually better than 1970
cat '#r/rtc' >/dev/time >[2]/dev/null

#fn showlocaldev {
#	echo $1'	' $2
#	if(~ $#bootargs 0){
#		if(! ~ $#cdboot 0){
#			if(~ $2 9660)
#				bootargs=local!$1
#		}
#		if not {
#			if(! ~ $2 '' dos)
#				bootargs=local!$1
#		}
#	}
#}
#
#fn showlocaldevs{
#	for(d in /dev/sd*) if(test -r $d/ctl){
#		q=`{sed 's,(inquiry|geometry),\
#\1,g' $d/ctl | grep inquiry}
#		echo $d':' $q(2-)
#		for(i in `{ls -p $d}){
#			p=$d/$i
#			switch($i){
#			case ctl raw log led
#				;
#			case plan9 nvram swap
#				echo $p
#			case *
#				showlocaldev $p `{fstype $p}
#			}
#		}
#	}
#	for(d in /shr/sd*) if(test -d $d) {
#		echo $d':'
#		for(p in $d/*.^(iso paq)) if(test -f $p){
#			t=`{fstype $p}
#			~ $#t 0 || showlocaldev $p $t
#		}
#	}
#}
#
#showlocaldevs

mac=`{cat /net/ether0/addr}
if{~ $"mac deadbeefcafe}{
	sysname=vmx9ferno
}{
	sysname=9ferno
}

#ns
	# disinit.b does this but not sure why it loses it later
	bind -c '#e' /env

if{~ $"sysname vmx9ferno}{
	# for using the cd
	9660srv /dev/sdF0/data /n/cd
	bind -a /n/cd/dis /dis
	#bind -a /n/cd/ /

	disk/fdisk -p /dev/sdG0/data >/dev/sdG0/ctl
	disk/prep -p /dev/sdG0/plan9 > /dev/sdG0/ctl

	### for formatting the disk
	###	bind -a '#S' /dev	# simple.b does this
	##disk/mbr -m mbr /dev/sdG0/data
	##disk/fdisk -baw /dev/sdG0/data
	##disk/prep -bw -a^(9fat fs) /dev/sdG0/plan9
	##disk/format -b pbs -d -r 2 /dev/sdG0/9fat 9bootfat /n/cd/cfg/plan9.ini
	#
	## for installing to a formatted disk
	#mount -c { disk/kfs -r -n root /dev/sdG0/fs } /n/rootdisk # ream
	#disk/kfscmd -n root sync
	#disk/mkfs -v -r -s /n/cd/ -d /n/rootdisk/ <{ echo + }
	#disk/kfscmd -n root sync

	## starting inferno already installed to a disk
	mount -c { disk/kfs -n rootdisk /dev/sdG0/fs } /n/rootdisk
	#disk/kfscmd -n rootdisk sync
	bind -b /n/rootdisk/dis /dis
	bind -a -c /n/rootdisk/ /

	# refresh the disk contents from the cd
	disk/mkfs -v -s /n/cd/ -d /n/rootdisk/ <{ echo + }

	mkdir -p /usr/`{cat /dev/user}
} &

<>/net/ipifc/clone {
	x=`{read}
	echo bind ether /net/ether0 > /net/ipifc/^$x^/ctl &&
	ip/dhcp -h $sysname -p /net/ipifc/$x
} &

cd /usr/`{cat /dev/user}
sh -l -n # to use the ./lib/profile