git: 9front

ref: 268014dbfef62dcb48045bb6844aa8f079e3fa9b
dir: /sys/src/9/boot/local.rc/

View raw version
#!/bin/rc

cddevs=()

# fill cddevs with cd or dvd devices
fn findcds{
	for(dev in /dev/sd*){
		x=`{sed '/([Cc][Dd]|[Dd][Vv][Dd])/!d' $dev/ctl >[2]/dev/null}
		if(! ~ $#x 0)
			cddevs=($cddevs $dev)
	}
}

fn configlocal{
	disk=`{echo $methodarg | sed 's,(.*)!.*,\1,g'}
	fstype=`{echo $disk | sed 's,.*/(.*)$,\1,g'}
	disk=`{echo $disk | sed 's,(.*)/.*$,\1,'}

	if(~ $pcload 1){
		kern=`{echo $methodarg | sed 's,.*!(.*)$,\1,g'}

		# for now we only allow kernels in the same dev/part of $methodargs
		if(~ $#kern 0 || ! ~ $#bootfile 0)
			kern=`{echo $bootfile | sed 's,.*!(.*)$,\1,g'}
	}

	bind -a '#c' /dev >/dev/null >[2=1] 
	bind '#p' /proc >[2=1] >/dev/null >[2=1]  
	bind -a '#S' /dev >/dev/null >[2=1] 
	bind -a '#f' /dev >/dev/null >[2=1] 
	bind -a '#k' /dev >/dev/null >[2=1] 
	bind -a '#æ' /dev >/dev/null >[2=1] 

	diskparts
	findcds
}

fn connectlocal{
	switch($fstype){
	case fossil
		connectlocalfossil
	case fs
		connectlocalkfs
	case data
		# test for cd/dvd
		x=`{sed '/([Cc][Dd]|[Dd][Vv][Dd])/!d' $disk^/ctl}
		if(! ~ $#x 0)
			must 9660srv -f $disk^/$fstype boot >/dev/null >[2=1]
	case *
		fatal unknown partition $fstype
	}
}

fn connectlocalfossil{
	if(! test -x /bin/fossil/fossil){
		echo no fossil
		exit nofossil
	}

	partition=$disk^/$fstype

	# settime(1, -1, nil)

	# make venti available

	# start fossil
	echo 'fossil('$partition')...'
	must fossil/fossil -f $partition -c 'srv -A boot' -c 'srv -p fscons'
}