#!/bin/sh
# fm_fls_auto written Fri Sep  9 17:19:10 PDT 1994 by valencia
logfile="/usr1/XFrame4.0/fminit/tmp/fm_fls.log"
usrdir="/usr1/XFrame4.0/fminit"
# How System V spells "rsh"
if [ -f /usr/bin/remsh ]; then
	rshcmd=/usr/bin/remsh
else
	rshcmd=rsh
fi
PATH="$PATH:/etc:/usr/etc"; export PATH # /usr/etc/rpcinfo
rpcinfo=rpcinfo prognum=300215 h=`hostname`
if [ X"$1" = Xlocalhost -o X"$1" = X$h ]; then
	echo "Attempting local auto-start of the Frame License Server."
	$FMHOME/bin/fm_fls -log $logfile -cd /tmp $usrdir/licenses &
else
	h=$1
	echo "Attempting remote auto-start of the Frame License Server on host $h."
	$rshcmd $h -n /bin/ls / > /dev/null 2>&1 || {
		echo "Failed to access ($rshcmd) remote FLS host $h."; exit 1
	}
	$rshcmd $h -n \
		$FMHOME/bin/fm_fls -log $logfile -cd /tmp $usrdir/licenses &
	if [ $? != 0 ]; then
		echo "Failed to access ($rshcmd) remote FLS on host $h."; exit 1
	fi
fi
ok=
for e in 10 10 20 20; do
	echo "Please wait a moment while the license server initializes..."
	sleep $e
	$rpcinfo -u $h $prognum >/dev/null 2>&1 && { ok=t; break;}
done
[ $ok ] && { echo "License server is ready."; exit 0;}
echo "License server failed."; exit 1
# LAST-LINE Fri Sep  9 17:19:10 PDT 1994
