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