#!/bin/ksh

if [ -f /etc/opt/SUNWisp/ixftagbls ]; then
        . /etc/opt/SUNWisp/ixftagbls
else
# Second tier case where SUNWixtnm is not needed and the admin servers need    
# not run.     
        return 0
fi

if [ -f  /etc/opt/SUNWisp/globals ]; then
        . /etc/opt/SUNWisp/globals
else
# Second tier case where SUNWixtnm is not needed and the admin servers need
# not run.
        return 0
fi

StartFtpadServ ()
{
  ${FTPADSERV_FILE} > /dev/null 2>&1 &
  FTPADSERV_PID=$!
  sleep ${SLEEP_TIME}
  WritePidFile `GetChildPidFromParent ${FTPADSERV_PID} ${FTPADSERV_FILE}` ${FTPADSERV_PID_FILE}
}

StopFtpadServ ()
{
  if [ -f ${FTPADSERV_PID_FILE} ]; then
	FTPADSERV_PID=`cat ${FTPADSERV_PID_FILE}`
	${KILL} ${FTPADSERV_PID} 2> /dev/null
  fi
}


Main ()
{
  if [ -f ${TNAMESERV_PID_FILE} ]; then
	pid=`cat ${TNAMESERV_PID_FILE}`
  fi
  if [ "${pid}X" != "X" ]; then
	  if [ "`CheckIfProcessAlive ${pid}`X" = "0X" ]; then
		StopFtpadServ
		CleanUp ${FTPADSERV_PID_FILE}
		StartFtpadServ
	  else
		echo "${TNAMESERV_FILE} process not running or not healthy"
	  fi
  fi
}

Main $*

