plan9fox/rc/bin/inst/main
cinap_lenrek 91cc172719 inst: fix pbs update for bootsetup, remove stopether and stopppp tasks
the pbs update might fail if we dont unmount the 9fat.
2012-12-20 11:17:10 +01:00

115 lines
1.8 KiB
Bash
Executable file

#!/bin/rc
. defs
while()
{
div=--------------------------------------
echo
echo $div
echo
echo -n 'Preparing menu...'
# must be topologically sorted (by prereq)
tasks=(\
systype\
configfs\
partdisk prepdisk\
mountfs\
configdist\
confignet\
mountdist\
download\
copydist\
ndbsetup nvramsetup\
tzsetup\
bootsetup\
finish\
)
# these don't show up in the menu but still matter
pseudotasks=(havefiles etherup etherdown pppup pppdown)
for(i in $tasks $pseudotasks)
$i=notdone
coherence
for(i in $tasks $pseudotasks)
if(~ $#$i 0)
$i=notdone
#
# we believe the environment about what is done
# only if we've confirmed it. since the tasks list is sorted so that
# prereqs of xxx come before xxx, it's okay to assume xxx
# is done until proven otherwise -- either a prereq or checkdone
# will say so.
#
done=()
ready=()
rm /env/done
rm /env/ready
for(i in $tasks) {
$i=done
for(j in `{prereq $i})
if(! ~ $$j done)
$i=notdone
if(~ $$i done) {
export $i
$i checkdone
$i=`{grep '^'$i^'=' /tmp/vars | sed -n '$p' | sed 's/.*=//'}
}
if(~ $$i notdone ready) {
okay=yes
for(j in `{prereq $i})
if(! ~ $$j done)
okay=no
switch($okay){
case yes
$i=ready
export $i
$i checkready
$i=`{grep '^'$i^'=' /tmp/vars | sed -n '$p' | sed 's/.*=//'}
case no
$i=notdone
}
}
if(~ $$i done ready)
$$i=($$$i $i) # rc can be just as complicated as perl!
}
export $tasks $pseudotasks done ready
coherence
echo
if(! ~ $#done 0) {
echo 'The following tasks are done: '
for(i in $done)
desc $i
echo
}
echo 'The following unfinished tasks are ready to be done:'
for(i in $ready)
desc $i
echo
if(~ $#ready 0) {
echo hey you finished everything! not supposed to happen.
sleep 100
exit
}
prompt -d $ready(1) -w '' 'Task to do' $done $ready
echo
echo $div
$rd go
$rd=done # if it's not, the check will figure that out
export $rd
}