Plan 9 from Bell Labs’s /usr/web/sources/patch/applied/inst-no-kfs/main

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/bin/rc

. defs

while()
{
div=--------------------------------------
echo
echo $div
echo
echo -n 'Preparing menu...'

# must be topologically sorted (by prereq)
tasks=(\
	partdisk prepdisk\
	fmtventi\
	fmtfossil\
	mountfs\
	configdist\
	confignet\
	mountdist\
	download\
	copydist\
	bootsetup finish stop\
	stopether stopppp\
)
#	startether startppp stopether stopppp download\

# these don't show up in the menu but still matter
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

#
# 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
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.