cvsdist c905793
#!/bin/sh
cvsdist c905793
#
cvsdist c905793
# nfs           This shell script takes care of starting and stopping
cvsdist c905793
#               the NFS services.
cvsdist c905793
#
cvsdist c905793
# chkconfig: - 60 20
cvsdist c905793
# description: NFS is a popular protocol for file sharing across TCP/IP \
cvsdist c905793
#              networks. This service provides NFS server functionality, \
cvsdist c905793
#              which is configured via the /etc/exports file.
cvsdist c905793
# probe: true
cvsdist e53021f
# config: /etc/sysconfig/nfs
cvsdist c905793
cvsdist c905793
# Source function library.
cvsdist c905793
. /etc/rc.d/init.d/functions
cvsdist c905793
cvsdist c905793
# Source networking configuration.
cvsdist c905793
if [ ! -f /etc/sysconfig/network ]; then
cvsdist c905793
    exit 0
cvsdist c905793
fi
cvsdist c905793
cvsdist c905793
. /etc/sysconfig/network
cvsdist c905793
cvsdist c905793
# Check that networking is up.
cvsdist 8fe6bc0
[ "${NETWORKING}" = "no" ] && exit 0
cvsdist c905793
cvsdist c905793
[ -x /usr/sbin/rpc.nfsd ] || exit 0
cvsdist c905793
[ -x /usr/sbin/rpc.mountd ] || exit 0
cvsdist c905793
[ -x /usr/sbin/exportfs ] || exit 0
cvsdist 1c22dc7
cvsdist 1c22dc7
# Don't fail if /etc/exports doesn't exist; create a bare-bones version and continue.
5089228
[ -r /etc/exports ] || \
5089228
    { touch /etc/exports && chmod u+rw,g+r,o+r /etc/exports ; } || \
cvsdist 1c22dc7
    { echo "/etc/exports does not exist" ; exit 0 ; }
cvsdist c905793
cvsdist e53021f
# Check for and source configuration file otherwise set defaults
cvsdist e53021f
[ -f /etc/sysconfig/nfs ] && . /etc/sysconfig/nfs
cvsdist e53021f
cvsdist 70faca5
[ -z "$MOUNTD_NFS_V2" ] && MOUNTD_NFS_V2=default
cvsdist 70faca5
[ -z "$MOUNTD_NFS_V3" ] && MOUNTD_NFS_V3=default
cvsdist e53021f
cvsdist 71d63d6
# Number of servers to be started by default
cvsdist e53021f
[ -z "$RPCNFSDCOUNT" ] && RPCNFSDCOUNT=8
cvsdist 6ae4499
cvsdist e53021f
# Remote quota server
cvsdist e53021f
[ -z "$RQUOTAD" ] && RQUOTAD=`type -path rpc.rquotad`
cvsdist e53021f
cvsdist c905793
# See how we were called.
cvsdist c905793
case "$1" in
cvsdist c905793
  start)
cvsdist c905793
	# Start daemons.
3f418c2
	[ -x /usr/sbin/rpc.svcgssd ] && /sbin/service rpcsvcgssd start
3f418c2
cvsdist 4bc0e7f
	action $"Starting NFS services: " /usr/sbin/exportfs -r
cvsdist 9d8f355
cvsdist 9d8f355
	# Set the ports lockd should listen on
cvsdist 4bc0e7f
	if [ -n "$LOCKD_TCPPORT" ]; then
cvsdist 9d8f355
	    /sbin/sysctl -w fs.nfs.nlm_tcpport=$LOCKD_TCPPORT >/dev/null 2>&1
cvsdist e53021f
	fi
cvsdist 4bc0e7f
	if [ -n "$LOCKD_UDPPORT" ]; then
cvsdist 9d8f355
	    /sbin/sysctl -w fs.nfs.nlm_udpport=$LOCKD_UDPPORT >/dev/null 2>&1
cvsdist 9d8f355
	fi
cvsdist 9d8f355
cvsdist e53021f
	if [ -n "$RQUOTAD" -a "$RQUOTAD" != "no" ]; then
cvsdist 9d8f355
	    echo -n $"Starting NFS quotas: "
44d986f
		[ -n "$RQUOTAD_PORT" ] \
44d986f
			&& RPCRQUOTADOPTS="$RPCRQUOTADOPTS -p $RQUOTAD_PORT"
44d986f
	    daemon rpc.rquotad $RPCRQUOTADOPTS
cvsdist 7a8b656
	    echo
cvsdist 7a8b656
	fi
cvsdist 0f7bdca
	echo -n $"Starting NFS daemon: "
50d268c
	daemon rpc.nfsd $RPCNFSDARGS $RPCNFSDCOUNT
cvsdist 0f7bdca
	echo
cvsdist e53021f
cvsdist e53021f
	[ -n "$MOUNTD_PORT" ] \
cvsdist e53021f
	&& RPCMOUNTDOPTS="$RPCMOUNTDOPTS -p $MOUNTD_PORT"
cvsdist e53021f
cvsdist e53021f
	case $MOUNTD_NFS_V2 in
cvsdist e53021f
	no|NO)
cvsdist 70faca5
	    RPCMOUNTDOPTS="$RPCMOUNTDOPTS --no-nfs-version 2" ;;
cvsdist e53021f
	esac
cvsdist e53021f
cvsdist e53021f
	case $MOUNTD_NFS_V3 in
cvsdist e53021f
	no|NO)
cvsdist 70faca5
	    RPCMOUNTDOPTS="$RPCMOUNTDOPTS --no-nfs-version 3" ;;
cvsdist e53021f
	esac
cvsdist e53021f
cvsdist e53021f
	echo -n $"Starting NFS mountd: "
cvsdist e53021f
	daemon rpc.mountd $RPCMOUNTDOPTS
cvsdist e53021f
	echo
cvsdist c905793
	touch /var/lock/subsys/nfs
cvsdist 4bc0e7f
3f418c2
	# Let rpc.idmapd know that rpc.mountd just started
cvsdist 4bc0e7f
	[ -x /usr/sbin/rpc.idmapd ] && /sbin/service rpcidmapd condstart
cvsdist 4bc0e7f
cvsdist c905793
	;;
cvsdist c905793
  stop)
cvsdist c905793
	# Stop daemons.
3f418c2
	[ -x /usr/sbin/rpc.svcgssd ] && /sbin/service rpcsvcgssd stop
cvsdist e53021f
	echo -n $"Shutting down NFS mountd: "
cvsdist c905793
	killproc rpc.mountd
cvsdist c905793
	echo
cvsdist e53021f
	echo -n $"Shutting down NFS daemon: "
cvsdist c905793
	killproc nfsd
cvsdist c905793
	echo
cc01757
	if [ -n "$RQUOTAD" -a "$RQUOTAD" != "no" ]; then
cvsdist 9d8f355
		echo -n $"Shutting down NFS quotas: "
cvsdist e53021f
		killproc rpc.rquotad
cvsdist e53021f
		echo
cvsdist 7a8b656
	fi
cvsdist 9d8f355
	# Reset the lockd ports if they were set
cvsdist 4bc0e7f
	if [ -n "$LOCKD_TCPPORT" ]; then
cvsdist 9d8f355
	    /sbin/sysctl -w fs.nfs.nlm_tcpport=0 >/dev/null 2>&1
cvsdist 9d8f355
	fi
cvsdist 4bc0e7f
	if [ -n "$LOCKD_UDPPORT" ]; then
cvsdist 9d8f355
	    /sbin/sysctl -w fs.nfs.nlm_udpport=0 >/dev/null 2>&1
cvsdist 9d8f355
	fi
cvsdist e53021f
	# Do it the last so that clients can still access the server
cvsdist e53021f
	# when the server is running.
cvsdist e53021f
	action $"Shutting down NFS services: " /usr/sbin/exportfs -au
cvsdist c905793
	rm -f /var/lock/subsys/nfs
cvsdist c905793
	;;
cvsdist c905793
  status)
3f418c2
	[ -x /usr/sbin/rpc.svcgssd ] && /sbin/service rpcsvcgssd status
3f418c2
	echo -n $"Shutting down NFS mountd: "
cvsdist c905793
	status rpc.mountd
cvsdist c905793
	status nfsd
cc01757
	if [ -n "$RQUOTAD" -a "$RQUOTAD" != "no" ]; then
cvsdist e53021f
		status rpc.rquotad
cvsdist 7a8b656
	fi
cvsdist c905793
	;;
cvsdist c905793
  restart)
cvsdist e53021f
	$0 stop
cvsdist e53021f
	$0 start
cvsdist c905793
	;;
cvsdist c905793
  reload)
cvsdist c905793
	/usr/sbin/exportfs -r
cvsdist c905793
	touch /var/lock/subsys/nfs
cvsdist c905793
	;;
cvsdist c905793
  probe)
cvsdist c905793
	if [ ! -f /var/lock/subsys/nfs ] ; then
cvsdist e53021f
	  echo $"start"; exit 0
cvsdist c905793
	fi
cvsdist c905793
	/sbin/pidof rpc.mountd >/dev/null 2>&1; MOUNTD="$?"
cvsdist c905793
	/sbin/pidof nfsd >/dev/null 2>&1; NFSD="$?"
cvsdist c905793
	if [ $MOUNTD = 1 -o $NFSD = 1 ] ; then
cvsdist e53021f
	  echo $"restart"; exit 0
cvsdist c905793
	fi
cvsdist c905793
	if [ /etc/exports -nt /var/lock/subsys/nfs ] ; then
cvsdist e53021f
	  echo $"reload"; exit 0
cvsdist c905793
	fi
cvsdist c905793
	;;
cvsdist 9d8f355
  condrestart)
3f418c2
	[ -x /usr/sbin/rpc.svcgssd ] && /sbin/service rpcsvcgssd condrestart
cvsdist 9d8f355
  	[ -f /var/lock/subsys/nfs ] && {
cvsdist 9d8f355
		$0 stop
cvsdist 9d8f355
		$0 start
cvsdist 9d8f355
	}
cvsdist 9d8f355
	;;
cvsdist c905793
  *)
cvsdist 9d8f355
	echo $"Usage: nfs {start|stop|status|restart|reload|condrestart}"
cvsdist c905793
	exit 1
cvsdist c905793
esac
cvsdist c905793
cvsdist c905793
exit 0