#!/bin/sh
#
# chkconfig:	345 60 20
# description:	The rusers protocol allows users on a network to locate \
#		users on any machine on that network.
# processname:	rpc.rusersd

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

# Get config.
. /etc/sysconfig/network

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

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

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

exit $RETVAL
