#! /bin/sh
#
# nis.init:     Start/Stop daemons for NIS+ client/server
#
# Author:       Thorsten Kukuk, <kukuk@suse.de>
#
# Version:      $Id: redhat.rc,v 1.2 1999/09/25 18:13:11 kukuk Exp $
#
# chkconfig: 345 51 49
# description: Starting the daemons for NIS+ and secure RPC

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

# Get config.
. /etc/sysconfig/network

# Run rpc.nisd in YP compat mode
#EMULYP=-Y

# Check that networking is up.
if [ ${NETWORKING} = "no" ]
then
	exit 0
fi

case "$1" in
  start)
 	echo -n "Starting NIS+ services: "
	daemon keyserv
	if [ -f /var/nis/NIS_COLD_START -a -f /usr/sbin/nis_cachemgr ]
	then
	    daemon nis_cachemgr
	fi
	if [ -d /var/nis/data -a -f /usr/sbin/rpc.nisd ]
	then
	   daemon rpc.nisd $EMULYP
	   daemon rpc.nispasswdd
	fi
	echo
	touch /var/lock/subsys/nisplus
	;;
  stop)
	echo -n "Stopping NIS+ services: "
	killproc keyserv
	if [ -f /var/nis/NIS_COLD_START -a -f /usr/sbin/nis_cachemgr ]
	then
	    killproc nis_cachemgr
	fi
	if [ -d /var/nis/data -a -f /usr/sbin/rpc.nisd ]
	then
	   killproc rpc.nisd
	   killproc rpc.nispasswdd
	fi
	echo
	rm -f /var/lock/subsys/nisplus
	;;
  status)
        status keyserv
	if [ -d /var/nis/NIS_COLD_START -a -f /usr/sbin/nis_cachemgr ]
	then
	    status nis_cachemgr
	fi
	if [ -d /var/nis/data -a -f /usr/sbin/rpc.nisd ]
	then
	   status rpc.nisd
	   status rpc.nispasswdd
	fi
        ;;
  restart)
        $0 stop
        $0 start
        ;;
  *)
	echo "Usage: nisplus {start|stop|status|restart}"
	exit 1
esac

exit 0
