#!/bin/bash

#. /etc/rc.conf
. /etc/rc.d/functions

name=monitis

MONITIS_HOME="/usr/local/monitis"
SLEEP=10

if [ -e /etc/monitis.conf ]; then
    . /etc/monitis.conf
fi

case "$1" in
  start)
    stat_busy "Starting $name daemon"
    /bin/bash ${MONITIS_HOME}/monitis.sh start > /dev/null &
    [ $? -eq 0 ] && { add_daemon $name; stat_done; } || { stat_fail; exit 1; }
    ;;
  stop)
    stat_busy "Stopping $name daemon"
    /bin/bash ${MONITIS_HOME}/monitis.sh stop > /dev/null && { rm_daemon $name; stat_done; } || { stat_fail; exit 1; }
    ;;
  restart|reload)
    $0 stop
    sleep $SLEEP
    $0 start
    ;;
  status)
    /bin/bash ${MONITIS_HOME}/monitis.sh status
    ;;
  *)
    echo "usage: $0 {start|stop|restart|status|reload}"  
    exit 1
esac
exit 0 
