~pixelherodev/ANTS

f74eeca46c0441da0b4dd48b6edf21e1dd67310d — Noam Preil 1 year, 6 months ago 944f86f
fshalt: better support for netbooting, venti, and fossil
1 files changed, 41 insertions(+), 13 deletions(-)

M rc/bin/fshalt
M rc/bin/fshalt => rc/bin/fshalt +41 -13
@@ 4,13 4,18 @@
rfork en
reboot=no
scram=no
switch ($#*) {
case 0
case 1
	reboot=yes
case *
	echo usage: $0 '[-r]' >[1=2]
	exit usage
while (~ $1 -*){
	switch($1){
	case -r
		reboot=yes
		shift
	case -n
		scram=noscram
		shift
	case *
		echo usage: $0 '[-r] [-n]' >[1=2]
		exit usage
	}
}

path=(/bin)


@@ 24,14 29,33 @@ sleep 1

c=`{ls /srv/cwfs*cmd >[2]/dev/null}
h=`{ls /srv/hjfs*cmd >[2]/dev/null}
f=`{ls /srv/fscons* >[2]/dev/null}

# for scram, don't scram other systems
bind -b '#P' /dev
if(! ~ $reboot yes){
	if (test -e '#P'/apm)
		scram=yes
	if (test -e '#P'/acpitbls -a -e '#P'/iow)
		scram=yes
if(! ~ $scram noscram){
	bind -b '#P' /dev
	if(! ~ $reboot yes){
		if (test -e '#P'/apm)
			scram=yes
		if (test -e '#P'/acpitbls -a -e '#P'/iow)
			scram=yes
	}
}

for(i in $f){
	echo -n $i
	venti/sync -h localhost >[2]/dev/null &
	venti/sync  >[2]/dev/null &
	sleep 2
	echo -n '...sync...'
	{
		echo
		echo 'fsys all sync'
		sleep 4
	} < $i >> $i
	venti/sync -h localhost >[2]/dev/null &
	venti/sync  >[2]/dev/null &
	sleep 2
}

# halting (binaries we run can't be on the fs we're halting)


@@ 61,6 85,10 @@ fn x {
		while(test -e $i)
			sleep 1
	}
	for(i in $f){
		echo fsys all halt >>$i
		sleep 3
	}
	echo
	echo done halting