#!/bin/bash
#
# dhisd           This shell script takes care of starting and stopping
#                 dhisd (Dynamic Host Information System server).
#
# chkconfig: 345 50 50
# description: dhisd is a Dynamic Host Information System (DHIS) server \
# that is used to subscribe host IP addresses into DNS dynamically.
# processname: dhisd
# config: /etc/dhis/db/dhis.db

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

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

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

[ -f /usr/sbin/dhisd ] || exit 0

[ -f /etc/dhis/db/dhis.db ] || exit 0

RETVAL=0

# See how we were called.
case "$1" in
	start)
        	echo -n "Starting dhisd: "
        	daemon dhisd
		RETVAL=$?
		echo
 		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/dhisd
		;;
	stop)
        	echo -n "Shutting down dhisd: "
        	killproc dhisd
		RETVAL=$?
        	echo
		[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/dhisd
		;;
	status)
        	status dhisd
		RETVAL=$?
		;;
	restart)
		$0 stop
		$0 start
		;;
	reload)
		killall -HUP dhisd
		RETVAL=$?
		;;
	*)
        	echo "Usage: dhisd {start|stop|status|restart|reload}"
		exit 1
esac

exit $?

