boot(8): fix boot restarting
This commit is contained in:
parent
06db9d4d68
commit
15656fc79d
3 changed files with 51 additions and 40 deletions
4
sys/lib/dist/pc/plan9.ini.cd
vendored
4
sys/lib/dist/pc/plan9.ini.cd
vendored
|
@ -1,8 +1,6 @@
|
||||||
# config for initial cd booting
|
# config for initial cd booting
|
||||||
*nodumpstack=1
|
*nomp=1
|
||||||
mouseport=ask
|
mouseport=ask
|
||||||
monitor=ask
|
monitor=ask
|
||||||
vgasize=ask
|
vgasize=ask
|
||||||
cdboot=yes
|
|
||||||
bootfile=/386/9pcf
|
bootfile=/386/9pcf
|
||||||
*nomp=1
|
|
||||||
|
|
|
@ -1,8 +1,32 @@
|
||||||
rfork e
|
#!/bin/rc
|
||||||
|
|
||||||
mt=()
|
bind -q '#p' /proc
|
||||||
. /rc/lib/tcp.rc
|
|
||||||
. /rc/lib/local.rc
|
bind -qa '#S' /dev
|
||||||
|
bind -qa '#f' /dev
|
||||||
|
bind -qa '#k' /dev
|
||||||
|
bind -qa '#æ' /dev
|
||||||
|
|
||||||
|
fn set {
|
||||||
|
a=$$1
|
||||||
|
$1=()
|
||||||
|
rm -f '#e'/$1 '#ec'/$1 /env/$1
|
||||||
|
if(! ~ $#a 0)
|
||||||
|
$1=$a
|
||||||
|
}
|
||||||
|
|
||||||
|
# convert plan9.ini variables
|
||||||
|
set init
|
||||||
|
set user
|
||||||
|
set nvram
|
||||||
|
set rootdir
|
||||||
|
set bootargs
|
||||||
|
set nobootprompt
|
||||||
|
set debugfactotum
|
||||||
|
set fs
|
||||||
|
set fsaddr
|
||||||
|
set auth
|
||||||
|
set authaddr
|
||||||
|
|
||||||
fn fatal {
|
fn fatal {
|
||||||
echo $*
|
echo $*
|
||||||
|
@ -32,18 +56,19 @@ fn ask {
|
||||||
ask $*
|
ask $*
|
||||||
}
|
}
|
||||||
|
|
||||||
fn getmethod{
|
mt=()
|
||||||
|
. /rc/lib/tcp.rc
|
||||||
|
. /rc/lib/local.rc
|
||||||
|
|
||||||
|
fn main{
|
||||||
mp=()
|
mp=()
|
||||||
while(~ $#mp 0){
|
while(~ $#mp 0){
|
||||||
if(~ $#nobootprompt 0){
|
if(~ $#nobootprompt 0){
|
||||||
echo
|
echo
|
||||||
showlocaldevs
|
showlocaldevs
|
||||||
ask bootargs ' are? (tcp, local!device)' $bootargs
|
ask bootargs ' is (tcp, local!device)' $bootargs
|
||||||
}
|
|
||||||
if not {
|
|
||||||
bootargs=$nobootprompt
|
|
||||||
nobootprompt=()
|
|
||||||
}
|
}
|
||||||
|
if not bootargs=$nobootprompt
|
||||||
mn=`{echo $bootargs | awk -F! '{print $1}'}
|
mn=`{echo $bootargs | awk -F! '{print $1}'}
|
||||||
ma=`{echo $bootargs | awk -F! '{print $2}'}
|
ma=`{echo $bootargs | awk -F! '{print $2}'}
|
||||||
for(i in `{seq 1 $#mt}){
|
for(i in `{seq 1 $#mt}){
|
||||||
|
@ -51,12 +76,6 @@ fn getmethod{
|
||||||
mp=$$mt($i)
|
mp=$$mt($i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fn main{
|
|
||||||
rm -f /srv/boot
|
|
||||||
|
|
||||||
getmethod
|
|
||||||
|
|
||||||
switch($mn){
|
switch($mn){
|
||||||
case local
|
case local
|
||||||
|
@ -81,16 +100,18 @@ fn main{
|
||||||
x=($x -p)
|
x=($x -p)
|
||||||
must $x
|
must $x
|
||||||
}
|
}
|
||||||
|
if not user=`{cat /dev/hostowner}
|
||||||
|
|
||||||
# connect method
|
# connect method
|
||||||
$mp(2) $ma
|
$mp(2) $ma
|
||||||
|
|
||||||
# mount root filesystem
|
# mount and change root in new enviroment and namespace
|
||||||
must mount -c /srv/boot /root
|
rfork ne
|
||||||
|
|
||||||
# start pager
|
# mount root filesystem
|
||||||
if(test -x /dev/swap)
|
if(~ $#rootdir 0)
|
||||||
echo -n start >/dev/swap
|
rootdir=/root
|
||||||
|
must mount -c /srv/boot $rootdir
|
||||||
|
|
||||||
# remove enviroment variables
|
# remove enviroment variables
|
||||||
rm -f /env/^$mt /env/? /env/?? '/env/fn#'*
|
rm -f /env/^$mt /env/? /env/?? '/env/fn#'*
|
||||||
|
@ -107,26 +128,16 @@ fn main{
|
||||||
# remove the remaining temporary root
|
# remove the remaining temporary root
|
||||||
/mnt/broot/$cputype/bin/unmount /mnt/broot
|
/mnt/broot/$cputype/bin/unmount /mnt/broot
|
||||||
|
|
||||||
rootdir=/root
|
|
||||||
|
|
||||||
if(~ $#init 0){
|
if(~ $#init 0){
|
||||||
init=/$cputype/init
|
init=/$cputype/init
|
||||||
if(~ $cpuflag 1)
|
if(~ $cpuflag 1)
|
||||||
init=($init -c)
|
init=($init -c)
|
||||||
if not
|
if not
|
||||||
init=($init -t)
|
init=($init -t)
|
||||||
# TODO handle mflag
|
|
||||||
}
|
}
|
||||||
exec $init
|
exec $init
|
||||||
}
|
}
|
||||||
|
|
||||||
bind -q '#p' /proc
|
|
||||||
|
|
||||||
bind -qa '#S' /dev
|
|
||||||
bind -qa '#f' /dev
|
|
||||||
bind -qa '#k' /dev
|
|
||||||
bind -qa '#æ' /dev
|
|
||||||
|
|
||||||
if(test -e '#u'){
|
if(test -e '#u'){
|
||||||
bind -a '#u' /dev
|
bind -a '#u' /dev
|
||||||
usb/usbd
|
usb/usbd
|
||||||
|
@ -140,7 +151,12 @@ if(! ~ $#kbmap 0){
|
||||||
|
|
||||||
configlocal # add partitions and binds
|
configlocal # add partitions and binds
|
||||||
|
|
||||||
while()@{
|
while(){
|
||||||
rfork ne
|
@{main}
|
||||||
main
|
sleep 1
|
||||||
|
|
||||||
|
# cleanup so it can be restarted
|
||||||
|
nobootprompt=()
|
||||||
|
user=()
|
||||||
|
rm -f /srv/boot /srv/slashn /srv/cs /srv/dns
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,12 +205,9 @@ srvremove(Chan *c)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Only eve can remove system services.
|
* Only eve can remove system services.
|
||||||
* No one can remove #s/boot.
|
|
||||||
*/
|
*/
|
||||||
if(strcmp(sp->owner, eve) == 0 && !iseve())
|
if(strcmp(sp->owner, eve) == 0 && !iseve())
|
||||||
error(Eperm);
|
error(Eperm);
|
||||||
if(strcmp(sp->name, "boot") == 0)
|
|
||||||
error(Eperm);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* No removing personal services.
|
* No removing personal services.
|
||||||
|
|
Loading…
Reference in a new issue