]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/src/9/boot/bootrc
provide /n and /mnt early in bootrc to allow consistent use in /lib/namespace
[plan9front.git] / sys / src / 9 / boot / bootrc
old mode 100644 (file)
new mode 100755 (executable)
index e1c90b5..b8c96cc
@@ -1,9 +1,14 @@
 #!/bin/rc
 
-mntgen -s slash /mnt
+# mount points
+mntgen -s slashn /n && chmod 666 /srv/slashn
+mntgen -s slashmnt /mnt && chmod 666 /srv/slashmnt
+mntgen -s mntexport /mnt/exportfs && chmod 666 /srv/mntexport
+
 bind /root /mnt/broot
 unmount /root
 
+bind -q '#d' /fd
 bind -q '#p' /proc
 for(i in S f k æ t b m)
        bind -qa '#'^$i /dev
@@ -16,15 +21,19 @@ for(i in I l^(0 1 2 3))
 cat '#r/rtc' >/dev/time >[2]/dev/null
 
 # reparse variables
-for(i in `{ls -Qp '#ec'}){
+for(i in `{ls -Qp /env}){
        switch($i){
-       case '*'* 
+       case '*'* 'fn#'* e820 apm0 apid ifs path pid prompt status ?
                # ignore these
        case *
                $i=`{echo $$i}
        }
 }
 
+fn sigint {
+       status=interrupted
+}
+
 fn fatal {
        echo $*
        exit $"*
@@ -38,7 +47,7 @@ fn ask {
        echo -n $1
        echo -n $2
        if(! ~ $#3 0){
-               echo -n ' ['
+               echo -n '['
                echo -n $3
                echo -n '] '
        }
@@ -54,8 +63,6 @@ fn ask {
 }
 
 mt=()
-. /rc/lib/tcp.rc
-. /rc/lib/local.rc
 
 fn main{
        mp=()
@@ -63,12 +70,13 @@ fn main{
                if(~ $#nobootprompt 0){
                        echo
                        showlocaldevs
-                       ask bootargs ' is (tcp, local!device)' $"bootargs
+                       ask bootargs ' is (tcp, il, local!device)' $"bootargs
                }
                if not bootargs=$nobootprompt
                nobootprompt=()
-               mn=`{echo $bootargs | awk -F! '{print $1}'}
-               ma=`{echo $bootargs | sed 's/[^!]*!?//'}
+               mn=`{echo $bootargs | sed 's,!, ,'}
+               ma=$mn(2-)
+               mn=$mn(1)
                switch(m$"mn){
                case $mt
                        mp=m$mn
@@ -76,27 +84,34 @@ fn main{
                }
        }
 
+       # authentication agent
+       if(! test -f /srv/factotum){
+               x=(/boot/factotum -n -sfactotum)
+               if(~ $service cpu){
+                       x=($x -S)
+                       if(~ -k $ff)
+                               x=($x -k)
+               }
+               if not
+                       x=($x -u)
+               if(! ~ $#debugfactotum 0)
+                       x=($x -p)
+               must $x
+       }
+
        # config method
        $mp(1) $ma
 
-       # authentication agent
-       if(test -f /srv/factotum){
-               rm -f /srv/factotum
-               user=`{cat /dev/hostowner}
-       }
-       x=(/boot/factotum -sfactotum)
-       if(~ $service cpu){
-               x=($x -S)
-               if(~ -k $ff)
-                       x=($x -k)
+       # load keys from secstore if $auth or $secstore is not empty
+       x=secstore
+       if(~ $#$x 0) x=auth
+       if(! ~ $#$x 0 && test -x /bin/auth/secstore && test -f /mnt/factotum/ctl){
+               x=(auth/secstore -G factotum -s^$$x)
+               if(~ $service cpu)
+                       $x -n >/mnt/factotum/ctl
+               if(~ $status *readnvram* || ! ~ $service cpu)
+                       $x >/mnt/factotum/ctl
        }
-       if not
-               x=($x -u)
-       if(! ~ $#authaddr 0)
-               x=($x -a $authaddr)
-       if(! ~ $#debugfactotum 0)
-               x=($x -p)
-       must $x
 
        # connect method
        $mp(2) $ma
@@ -135,7 +150,7 @@ fn main{
        }
 
        # remove enviroment variables
-       rm -f /env/^$mt /env/? /env/?? '/env/fn#'* 
+       rm -f '#e/'^$mt '#e/'? '#e/'?? '#e/fn#'* 
 
        # remove part of our temporary root
        /mnt/broot/$cputype/bin/unmount /$cputype/bin /bin
@@ -161,7 +176,15 @@ if(test -x /bin/aux/kbdfs){
 }
 
 # usb devices
-nusbrc
+if(test -x /bin/nusbrc && ! test -e /env/nousbrc)
+       nusbrc
+
+# load boot methods
+fn showlocaldevs {}
+fn configlocal {}
+for(i in /rc/lib/*.rc){
+       . $i
+}
 
 # add partitions and binds
 configlocal
@@ -205,8 +228,10 @@ if(! ~ $#aa 0 && ~ $#bootargs 0 && ~ $#nobootprompt 0){
 while(){
        @{main}
 
+       # subshell doesnt wait on interrupts
+       while(~ $status interrupted){wait}
+
        # cleanup so it can be restarted
        nobootprompt=()
-       user=()
-       rm -f /srv/^(cfs boot slashn cs dns)
-} </dev/cons >/dev/cons >[2]/dev/cons 
+       rm -f /srv/^(cfs boot cs dns)
+} </dev/cons