#!/bin/sh
#
# ugidd       This shell script takes care of starting and stopping
#              the NFS uid/gidd mapping daemon.
#
# chkconfig: - 14 86
# description: NFS is a popular protocol for file sharing across \
#	       TCP/IP networks. This service provides NFS uid/gidd \
#	       mapping functionality.
# processname: rpc.ugidd
# pidfile: /var/run/rpc.ugidd.pid

WITHOUT_RC_COMPAT=1

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

# Source networking configuration.
# Check that networking is up.
SourceIfNotEmpty /etc/sysconfig/network && [ "$NETWORKING" != no ] || exit

UGIDD=/usr/sbin/rpc.ugidd

[ -x "$STATD" ] || exit

PIDFILE=/var/run/rpc.ugidd.pid
LOCKFILE=/var/lock/subsys/ugidd
RETVAL=0

start()
{
	start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" $UGIDD
	RETVAL=$?
	return $RETVAL
}

stop()
{
	stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" $UGIDD
	RETVAL=$?
	return $RETVAL
}

restart()
{
	stop
	start
}

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

exit $RETVAL
