#!/bin/rc
#
# check host ability
#
rfork ens
if(! ~ $#* 1){
	echo 'usage: check thema'
	exit usage
}

T=$1  # job thema
if(! test -e $T/host){
	echo no host in $T
	exit usage
}

glib=$home/lib/grid
dom=`{ls -p $glib}

# we select doms that we have factotum for
do=()
for(d in $dom){
	if(test -e $glib/$d/factotum)
		do=($do $d)
}
dom=$do

auth/factotum -n
for(d in $dom){
	read $glib/$d/factotum >/mnt/factotum/ctl
}

bind -b bin/$objtype /bin
bind -b bin/rc /bin
bind -bc $T /usr/none

cd /usr/none

# on exiting ...

for(d in $dom){
	hosts=`{grep -v '^#' $glib/$d/names}
	for(host in $hosts){
		echo login $host
		mrun $host &
	}
}
wait
echo finished
