shithub: 9ferno

ref: 957c1191e660f4ff75ec9e847377ba70deb7d0ee

View raw version
# boot initialization
#	configure devices
#	setup /
# sh -n /dis/init

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

load std

mount {mntgen} /n
mount {mntgen} /mnt

#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
}{~ $"mac 6805ca1bae72}{
	sysname=9ferno
}{
	sysname=9ferno1
}

echo $"sysname > '#c'/sysname

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

#ns
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 + } &

}{~ $"sysname 9ferno}{

	# mount the vmx cd
	mount -A tcp!192.168.88.118!17001 /n/cd
	bind -b /n/cd/dis /dis
	bind -a /n/cd /

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

}

# if I add /lib/sh/profile to devroot,
#	all the above binds can be moved to $home/namespace
sh -x -l -n # to run the /lib/sh/profile