#!/bin/bash
#
# chkconfig: 345 90 12
#
# Copyright 2012 by Overlook
# description: Fingbox Sentinel
#
# Get function from functions library
. /etc/init.d/functions
# Start the service
start() {
        echo -n "Starting fingbox-sentinel: "
	export LD_LIBRARY_PATH="/usr/lib/fing"
	export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH
	ulimit -n 1024
	ulimit -c 0
	nohup /usr/lib/fing/fing.bin --sentinel >/dev/null 2>/dev/null &
	echo $! > /var/run/fingbox-sentinel.pid
        ### Create the lock file ###
        touch /var/lock/subsys/fingbox-sentinel
        success $"fingbox-sentinel startup"
        echo
}
# Restart the service
stop() {
        echo -n "Stopping fingbox-sentinel: "
        killproc fingbox-sentinel
        ### Now, delete the lock file ###
        rm -f /var/lock/subsys/fingbox-sentinel
        echo
}
### main logic ###
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        status fingbox-sentinel
        ;;
  restart|reload|condrestart)
        stop
        start
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|reload|status}"
        exit 1
esac
exit 0
