#!/bin/sh
#
# chkconfig:	345 60 20
#
# description:	The rwho protocol lets remote users get a list of all of \
#		the users logged into a machine running the rwho daemon \
#		(similiar to finger).
#
# processname: rwhod

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

# Get network config
. /etc/sysconfig/network

# Get service config
[ -f /etc/sysconfig/rwhod ] && . /etc/sysconfig/rwhod

# Check that networking is up.
if is_no "${NETWORKING}"; then
	msg_Network_Down rwhod
	exit 1
fi

# See how we were called.
case "$1" in
  start)
	# Check if the service is already running?
	if [ ! -f /var/lock/subsys/rwhod ]; then
		msg_starting rwhod
		daemon rwhod
		RETVAL=$?
		if [ $RETVAL -eq 0 ]; then
			touch /var/lock/subsys/rwhod
			RETVAL=1
		fi
	else
		msg_Already_Running rwhod
		exit 1
	fi
	;;
  stop)
	if [ -f /var/lock/subsys/rwhod ]; then
		msg_stopping rwhod
		killproc rwhod
		rm -f /var/lock/subsys/rwhod >/dev/null 2>&1
	else
		msg_Not_Running rwhod
		exit 1
	fi	
	;;
  status)
	status rwhod
	;;
  reload|restart|force-reload)
	$0 stop
	$0 start
	;;
  *)
	msg_Usage "$0 {start|stop|status|restart|reload|force-reload}"
	exit 1
	;;
esac

exit $RETVAL
