#!/bin/sh
x=`basename $0`
u="$x [-x] [-v] [-r] [ hosts ... ]"
#	SID	"@(#)mkalltraits.sh	8.5 - 99/12/15"
if [ X"$1" = X-x ] ; then
	cat <<!
$u

run mktraits on remote hosts

-x		display this explanation
-v		add -v flag to qremote commands
-r		use rsh command instead of qremote
hosts ...	hosts to be processed

mktraits is run, using qremote, on all hosts for which a X.qtree
variable exists in the qdsrv database.

To get a list of such variables, use:

	qdmgt vlist \*.qtree
!
	exit 1
fi
Vflag=
Rflag=0
while [ $# -gt 0 ] ; do
	case X$1 in
	X-v)	Vflag=-v ;;
	X-r)	Rflag=1 ;;
	X-*)
		necho -e -- "$x $X: invalid flag\nUsage: $u"
		exit 1 ;;
	X*)	break ;;
	esac
	shift
done
if [ $# -gt 0 ] ; then
	hosts=$*
else
	hosts=`qdmgt vlist \*.qtree | sed 's/\.qtree = .*//'`
fi
if [ $Rflag -eq 0 ] ; then
	lash -o "qremote $VFLAG -h %1 mktraits -u" $hosts
	exit
fi
for H in $hosts ; do
	Q=`qdmgt vget $H.qtree`
	if [ "$Q" = "" ] ; then
		necho -e "$x: $H.qtree undefined so cannot rsh to $H"
		continue
	fi
	echo "rsh $H $Q/bin/cush -Q $Q/bin/mktraits -u"
	rsh $H $Q/bin/cush -Q $Q/bin/mktraits -u
done
