#!/bin/bash
#
# Init file for Osiris Scanning daemon
#
# description: osiris scanning daemon
#
# processname: osirisd 

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

RETVAL=0
prog="osirisd"

# Some functions to make the below more readable
OSIRISD="@INSTALLDIR@/osirisd"


start()
{
	echo -n $"Starting $prog:"
	initlog -c "$OSIRISD $OPTIONS" && success || failure
	RETVAL=$?
	[ "$RETVAL" = 0 ] && touch /var/lock/subsys/osirisd
	echo
}

stop()
{
	echo -n $"Stopping $prog:"
	killproc $OSIRISD -TERM
	RETVAL=$?
	[ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/osirisd
	echo
}

reload()
{
	echo -n $"Reloading $prog:"
	killproc $OSIRISD -HUP
	RETVAL=$?
	echo
}

case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	restart)
		stop
		start
		;;
	reload)
		reload
		;;
	condrestart)
		if [ -f /var/lock/subsys/osirisd ] ; then
			stop
			# avoid race
			sleep 3
			start
		fi
		;;
	status)
		status $OSIRISD
		RETVAL=$?
		;;
	*)
		echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}"
		RETVAL=1
esac
exit $RETVAL
