#!/bin/bash
# Script to make node wait for NFS from head to come up
#
if [ "$HEAD" == "" ] ; then
  HEAD="head"
fi

echo -n "Waiting for head node: $HEAD to provide RPC services..."
declare -i count=10
found="no"
while [ $count -ge 1 -a $found != "yes" ]
  do
    if [ $count -le 9 ] ; then
      echo
      echo -n "Still not found.. retrying after 15 seconds..."
      sleep 15s
    fi
    rpcinfo -s $HEAD >&/dev/null
    if [ $? -eq 0 ] ; then found="yes" ; fi
      count=$count-1
done
if [ $found == "yes" ] ; then 
  echo success ; RETVAL=0
else 
  echo failure ; RETVAL=1
fi
echo
exit $RETVAL
