#!/bin/sh
#
#  Cleo node monitor start/stop script
#
#


######################################
###   SUPPORTING SUBROUTINES
######################################

stop_q ()
{
    pid=`ps |grep -v grep|grep cleo-mon| cut -d \  -f 2`
    if [ "x$pid" != "x" ]; then
      kill $pid
    fi
}

start_q ()
{
    /usr/sbin/cleo-mon
}

######################################
##  THE SCRIPT MAIN PART
######################################


case "$1" in
  start)
    echo -n "Starting Cleo monitor... "
    start_q;
    echo "done"
    ;;
  stop)
    echo -n "Stopping Cleo monitor... "
    stop_q;
    echo "done"
    ;;
  restart)
    echo -n "Restarting Cleo monitor... "
    stop_q;
    start_q;
    echo "done"
    ;;
  *)
    echo "usage: $0 {start|stop|restat}"
    exit 1
esac

exit 0
