#!/bin/rc while() { div=-------------------------------------- echo echo $div echo # must be topologically sorted (by prereq) tasks=(pickdisk partdisk prepdisk reamfs mountfs \ configarch startether startppp download stopppp \ unpack bootsetup finish stop stopether) pseudotasks=(configip havefiles etherup etherdown pppup pppdown) for(i in $tasks $pseudotasks) $i=notdone coherence for(i in $tasks $pseudotasks) if(~ $#$i 0) $i=notdone # # for the most part we believe the environment # about whether something is done, but it # must be consistent with the prerequisites # and we let the module confirm as well. # done=() ready=() rm /env/done rm /env/ready for(i in $tasks) { if(~ $$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 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 }