#!/bin/sh
#
# ypserv:       Starts the yp-server
#
# chkconfig:	345 41 64
#
# description:	ypserv is an implementation of the standard NIS/YP networking \
#		protocol. It allows network-wide distribution of hostname, \
#		username, and other information databases. This is the NIS \
#		server, and is not needed on NIS clients.
#
# processname:	ypserv
# config:	/etc/ypserv.conf


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

# Get network config
. /etc/sysconfig/network

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

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

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

exit 0

