#!/bin/sh
# chkconfig: - 90 12
# description: dhid is DHIS client daemon.

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

# Source networking configuration and check that networking is up.
if [ -f /etc/sysconfig/network ] ; then
	. /etc/sysconfig/network
	[ ${NETWORKING} = "no" ] && exit 0
fi

[ -x /usr/sbin/dhid ] || exit 0


RETVAL=0

start () {
    [ -r /etc/dhid.conf ] || exit 0
    echo -n "Starting DHIS client daemon: "
    daemon /usr/sbin/dhid
    RETVAL=$?
    echo
    [ $RETVAL = 0  ]&& touch /var/lock/subsys/dhid
    return $RETVAL
}

stop () {
    echo -n "Stopping DHIS client daemon: "
    killproc /usr/sbin/dhid
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && rm -f /var/lock/subsys/dhid
    return $RETVAL
}

restart () {
    stop
    start
    RETVAL=$?
    return $RETVAL
}

# See how we were called.
case "$1" in
    start)
        start
	;;
    stop)
        stop
	;;
    status)
	status /usr/sbin/dhid
	RETVAL=$?
	;;
    restart)
	restart
	;;
    *)
        echo "Usage: dhid {start|stop|restart|status}"
        RETVAL=1
esac

exit $RETVAL
