#!/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_yes "${NETWORKING}"; then
	if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
		msg_network_down rusersd
		exit 1
	fi
else
	exit 0
fi

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

RETVAL=0
# 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=$?
		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/rusersd
	else
		msg_already_running rusersd
	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
	fi	
	;;
  status)
	status rpc.rusersd
	exit $?
	;;
  restart|force-reload)
	$0 stop
	$0 start
	exit $?
	;;
  *)
	msg_usage "$0 {start|stop|restart|force-reload|status}"
	exit 3
esac

exit $RETVAL
