#!/bin/bash
# chkconfig: 2345 95 20
# description: Starts WiKID server
# What your script does (not sure if this is necessary though)
# processname: wikid
#echo "Starting wikid"

# Source function library.
. /etc/rc.d/init.d/functions


wikid="/opt/WiKID/bin/wikidctl start"
prog="/opt/WiKID/bin/wikidctl"

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

lockfile=/var/lock/subsys/wikid

RETVAL=0

start()
{
    echo "Starting wikid"
    daemon $wikid
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}
stop () 
{
   echo "Stopping WiKID"   
   /opt/WiKID/bin/wikidctl stop
}
status()
{
  /opt/WiKID/bin/wikidctl status
}

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        status wikid
        RETVAL=$?
        ;;
  restart)
        stop
        start
        ;;
  condrestart)
        if [ -f /var/lock/subsys/wikid ]; then
          stop
          start
        fi
        ;;
  reload)
        echo -n $"Re-reading $prog configuration: "
        killproc wikid -HUP
        RETVAL=$?
        echo
        ;;
  *)
        echo "Usage: $prog {start|stop|restart|reload|condrestart|status}"
        exit 1
esac

exit $RETVAL
