#!/bin/sh
#
# portmap       Start/Stop RPC portmapper
#
# chkconfig:	345 11 89
#
# description:	The portmapper manages RPC connections, which are used by \
#		protocols such as NFS and NIS. The portmap server must be \
#		running on machines which act as servers for protocols which \
#		make use of the RPC mechanism.
# processname:	portmap


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

# Get network config
. /etc/sysconfig/network

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

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

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

exit 0
