walters / rpms / nfs-utils

Forked from rpms/nfs-utils 6 years ago
Clone
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 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 c905793
[ ${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.
cvsdist 1c22dc7
[ -s /etc/exports ] || \
cvsdist 1c22dc7
    { echo "#" > /etc/exports && chmod u+rw,g+r,o+r /etc/exports ; } || \
cvsdist 1c22dc7
    { echo "/etc/exports does not exist" ; exit 0 ; }
cvsdist c905793
cvsdist 71d63d6
# Number of servers to be started by default
cvsdist c905793
RPCNFSDCOUNT=8
cvsdist 71d63d6
cvsdist 71d63d6
# NFSv3 only if kernel >= 2.2.18
cvsdist 71d63d6
OS_RELEASE=`uname --release`
cvsdist 71d63d6
OS_RELEASE_MINOR=`echo "$OS_RELEASE" | sed 's/\(^[0-9]\)\.\([0-9]*\).*/\2/'`
cvsdist 71d63d6
OS_RELEASE_VERSION=`echo "$OS_RELEASE" | sed 's/\(^[0-9]\)\.\([0-9]*\)\.\([0-9]*\).*/\3/'`
cvsdist 71d63d6
if [ "$OS_RELEASE_MINOR" -gt 2 ]; then
cvsdist 71d63d6
	RPCMOUNTDOPTS=
cvsdist 71d63d6
elif [ "$OS_RELEASE_MINOR" -eq 2 -a "$OS_RELEASE_VERSION" -ge 18 ]; then
cvsdist 71d63d6
	RPCMOUNTDOPTS=
cvsdist 71d63d6
else
cvsdist 71d63d6
	RPCMOUNTDOPTS="--no-nfs-version 3"
cvsdist 71d63d6
fi
cvsdist c905793
cvsdist 7a8b656
if [ -n "$MOUNTD_PORT" ]; then
cvsdist 7a8b656
    RPCMOUNDOPTS="$RPCMOUNTDOPTS --port $MOUNTD_PORT"
cvsdist 7a8b656
fi
cvsdist 7a8b656
cvsdist c905793
# See how we were called.
cvsdist c905793
case "$1" in
cvsdist c905793
  start)
cvsdist c905793
	# Start daemons.
cvsdist 7a8b656
	action "Starting NFS services: " /usr/sbin/exportfs -r
cvsdist 7a8b656
	if [ -x /usr/sbin/rpc.rquotad ] ; then
cvsdist 7a8b656
	    echo -n "Starting NFS quotas: "
cvsdist 7a8b656
	    daemon rpc.rquotad
cvsdist 7a8b656
	    echo
cvsdist 7a8b656
	fi
cvsdist 7a8b656
	echo -n "Starting NFS mountd: "
cvsdist c905793
	daemon rpc.mountd $RPCMOUNTDOPTS
cvsdist c905793
	echo
cvsdist 7a8b656
	echo -n "Starting NFS daemon: "
cvsdist c905793
	daemon rpc.nfsd $RPCNFSDCOUNT
cvsdist c905793
	echo
cvsdist c905793
	touch /var/lock/subsys/nfs
cvsdist c905793
	;;
cvsdist c905793
  stop)
cvsdist c905793
	# Stop daemons.
cvsdist 7a8b656
	echo -n "Shutting down NFS mountd: "
cvsdist c905793
	killproc rpc.mountd
cvsdist c905793
	echo
cvsdist 7a8b656
	echo -n "Shutting down NFS daemon: "
cvsdist c905793
	killproc nfsd
cvsdist c905793
	echo
cvsdist 7a8b656
	action "Shutting down NFS services: " /usr/sbin/exportfs -au
cvsdist 7a8b656
	if [ -x /usr/sbin/rpc.rquotad ] ; then
cvsdist 7a8b656
	    echo -n "Shutting down NFS quotas: "
cvsdist 7a8b656
	    killproc rpc.rquotad
cvsdist 7a8b656
	    echo
cvsdist 7a8b656
	fi
cvsdist c905793
	rm -f /var/lock/subsys/nfs
cvsdist c905793
	;;
cvsdist c905793
  status)
cvsdist c905793
	status rpc.mountd
cvsdist c905793
	status nfsd
cvsdist 7a8b656
	if [ -x /usr/sbin/rpc.rquotad ] ; then
cvsdist 7a8b656
	    status rpc.rquotad
cvsdist 7a8b656
	fi
cvsdist c905793
	;;
cvsdist c905793
  restart)
cvsdist 7a8b656
	echo -n "Restarting NFS services: "
cvsdist 7a8b656
	echo -n "rpc.mountd "
cvsdist c905793
	killproc rpc.mountd
cvsdist c905793
	daemon rpc.mountd $RPCMOUNTDOPTS
cvsdist c905793
	/usr/sbin/exportfs -r
cvsdist c905793
	touch /var/lock/subsys/nfs
cvsdist 1ea8452
	echo
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 c905793
	  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 c905793
	  echo restart; exit 0
cvsdist c905793
	fi
cvsdist c905793
	if [ /etc/exports -nt /var/lock/subsys/nfs ] ; then
cvsdist c905793
	  echo reload; exit 0
cvsdist c905793
	fi
cvsdist c905793
	;;
cvsdist c905793
  *)
cvsdist 7a8b656
	echo "Usage: $0 {start|stop|status|restart|reload}"
cvsdist c905793
	exit 1
cvsdist c905793
esac
cvsdist c905793
cvsdist c905793
exit 0
cvsdist c905793