diff --git a/rc/bin/termrc b/rc/bin/termrc index f4cb46159..e13450dde 100755 --- a/rc/bin/termrc +++ b/rc/bin/termrc @@ -8,6 +8,7 @@ mntgen -s slashn && chmod 666 /srv/slashn # bind all likely devices (#S was bound in boot) for(i in f t m v L P u U '$' Σ κ) /bin/bind -a '#'^$i /dev >/dev/null >[2=1] +rm -f /env/i # set up any partitions diskparts @@ -16,7 +17,7 @@ diskparts disk=`{ls /dev/sd*/swap >[2]/dev/null} if (! ~ $#disk 0) swap $disk(1) >/dev/null >[2=1] -rm /env/disk +rm -f /env/disk # we do this before we have a name. we may need to do network # setup so that we can get a name. @@ -107,6 +108,7 @@ if(! ~ $"vgasize '' text none){ } } } +rm -f '/env/fn#ask' usbstart if (test -f /dev/apm) diff --git a/sys/src/9/boot/bootrc b/sys/src/9/boot/bootrc index eb00799be..e056e77bc 100644 --- a/sys/src/9/boot/bootrc +++ b/sys/src/9/boot/bootrc @@ -1,21 +1,8 @@ -# TODO -# settime -# handle rootspec -# handle rootdir -# clean rc environment before running init(8) -# kfs -# caching - rfork e -# boot methods -mlocal = (configlocal connectlocal) -mtcp = (configtcp connecttcp) -mtab = (mlocal mtcp) -config=1 -connect=2 -. /rc/lib/local.rc +mt=() . /rc/lib/tcp.rc +. /rc/lib/local.rc fn fatal { echo $* @@ -29,7 +16,7 @@ fn must { fn ask { echo -n $1 echo -n $2 - if(! ~ $#3 0){ + if(! ~ $3 ''){ echo -n ' [' echo -n $3 echo -n '] ' @@ -45,44 +32,42 @@ fn ask { ask $* } -fn readmethod{ - found=0 - while(~ $found 0){ +fn getmethod{ + mp=() + while(~ $#mp 0){ if(~ $#nobootprompt 0){ echo showlocaldevs - ask bootargs ' are? (tcp, local!device)' $"bootargs + ask bootargs ' are? (tcp, local!device)' $bootargs } if not { bootargs=$nobootprompt nobootprompt=() } - method=`{echo $bootargs | awk -F! '{print $1}'} - NF=`{echo $bootargs | awk -F! '{print NF}'} - for(i in `{seq 1 $#mtab}){ - if(~ $mtab($i) m^$method) - found=$i + mn=`{echo $bootargs | awk -F! '{print $1}'} + ma=`{echo $bootargs | awk -F! '{print $2}'} + for(i in `{seq 1 $#mt}){ + if(~ $mt($i) m^$mn) + mp=$$mt($i) } - if(~ $found 0) - echo method $method not found } - methodarg = `{echo $bootargs | awk -F! '{print $2}'} - mp = $$mtab($found) } fn main{ rm -f /srv/boot - readmethod - $mp($config) $methodarg + getmethod - switch($method){ + switch($mn){ case local islocal=1 case hybrid ishybrid=1 } + # config method + $mp(1) $ma + # authentication agent if(! test -f /srv/factotum){ x=(/boot/factotum -sfactotum) @@ -97,8 +82,8 @@ fn main{ must $x } - # connect to the root file system - $mp($connect) $methodarg + # connect method + $mp(2) $ma # mount root filesystem must mount -c /srv/boot /root @@ -107,6 +92,9 @@ fn main{ if(test -x /dev/swap) echo -n start >/dev/swap + # remove enviroment variables + rm -f /env/^$mt /env/? /env/?? '/env/fn#'* + # remove part of our temporary root /mnt/broot/$cputype/bin/unmount /$cputype/bin /bin /mnt/broot/$cputype/bin/unmount /rc/bin /bin @@ -142,7 +130,6 @@ bind -qa '#æ' /dev if(test -e '#u'){ bind -a '#u' /dev usb/usbd - sleep 1 } if(! ~ $#kbmap 0){ @@ -154,6 +141,6 @@ if(! ~ $#kbmap 0){ configlocal # add partitions and binds while()@{ - rfork n + rfork ne main } diff --git a/sys/src/9/boot/local.rc b/sys/src/9/boot/local.rc index d17584735..1fd91e481 100644 --- a/sys/src/9/boot/local.rc +++ b/sys/src/9/boot/local.rc @@ -20,8 +20,6 @@ fn showlocaldevs{ fn configlocal{ if(~ $pcload 1){ kern=`{echo $* | 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'} } @@ -41,3 +39,6 @@ fn connectlocal{ } {$t -s -f $* &} <[0=1] | echo 0 >/srv/boot } + +mlocal=(configlocal connectlocal) +mt=(mlocal $mt) diff --git a/sys/src/9/boot/tcp.rc b/sys/src/9/boot/tcp.rc index 596f1521c..18e45edb2 100755 --- a/sys/src/9/boot/tcp.rc +++ b/sys/src/9/boot/tcp.rc @@ -3,7 +3,7 @@ fn configtcp{ # bind in an ip interface for(i in I l`{seq 0 3}) - bind -a '#'$i /net >/dev/null >[2=1] + bind -qa '#'$i /net must ip/ipconfig -p $* @@ -12,9 +12,9 @@ fn configtcp{ if(~ $#auth 0) auth=`{awk -F'=' '/auth=/{print $2; exit}' /net/ndb} if(~ $#fs 0) - ask fs ' ip is?' $"auth + ask fs ' ip is?' $auth if(~ $#auth 0) - ask auth ' ip is?' $"fs + ask auth ' ip is?' $fs fsaddr=tcp!$fs!564 authaddr=tcp!$auth!567 @@ -23,3 +23,6 @@ fn configtcp{ fn connecttcp{ srv -q $"fsaddr boot } + +mtcp=(configtcp connecttcp) +mt=(mtcp $mt)