#!/bin/sh
### BEGIN INIT INFO
# Provides: whosond
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $network $remote_fs $syslog
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: whosond - implementation of WHOSON protocol
# Description: whosond - implementation of WHOSON protocol
### END INIT INFO

# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1

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

# Get network config
. /etc/sysconfig/network

# Get service config
SourceIfNotEmpty /etc/sysconfig/whoson

LOCKFILE=/var/lock/subsys/whosond
RETVAL=0

start()
{
	start_daemon --lockfile "$LOCKFILE" --expect-user nobody whosond
	RETVAL=$?
        return $RETVAL
}

stop()
{
	stop_daemon --lockfile "$LOCKFILE" --expect-user nobody whosond
	RETVAL=$?
	return $RETVAL
}

restart()
{
        stop
        start
}

reload()
{
	msg_reloading whosond
	stop_daemon --pidfile "$PIDFILE" --expect-user nobody -HUP whosond
	RETVAL=$?
	return $RETVAL
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart)
	restart
	;;
  reload|force-reload)
	reload
	;;
  condstop)
	if [ -e "$LOCKFILE" ]; then
		stop
	fi
	;;
  condrestart)
	if [ -e "$LOCKFILE" ]; then
		restart
	fi
	;;
  condreload)
	if [ -e "$LOCKFILE" ]; then
		reload
	fi
	;;
  status)
	status --expect-user nobody whosond
	RETVAL=$?
        ;;
  *)
	msg_usage "Usage: ${0##*/} {start|stop|status|reload|force-reload|restart|condstop|condrestart|condreload}"
        RETVAL=1
esac

exit $RETVAL
