#!/bin/sh
#
-# nfs This shell script takes care of starting and stopping
-# the NFS services. Later we might add NIS too.
+# nfs This shell script takes care of starting and stopping
+# the NFS services.
#
-# chkconfig: 345 60 20
-# description: NFS is a popular protocol for file sharing across TCP/IP \
-# networks. This service provides NFS server functionality, \
-# which is configured via the /etc/exports file.
-# probe: true
+# chkconfig: 345 60 20
+# description: NFS is a popular protocol for file sharing across TCP/IP \
+# networks. This service provides NFS server functionality, \
+# which is configured via the /etc/exports file.
+# probe: true
-# Source function library.
+# Source function library
. /etc/rc.d/init.d/functions
-# Source networking configuration.
+# Get network config
. /etc/sysconfig/network
+# Get service config
+[ -f /etc/sysconfig/nfsd ] && . /etc/sysconfig/nfsd
+
# Check that networking is up.
-[ "${NETWORKING}" = "no" ] && exit 0
+if is_no "${NETWORKING}"; then
+ msg_Network_Down NFSD
+ exit 1
+fi
-[ -f /usr/sbin/rpc.nfsd ] || exit 0
-[ -f /usr/sbin/rpc.mountd ] || exit 0
+if [ -x /sbin/pidof ] && [ "$1" != "stop" ]; then
+ [ -z "`/sbin/pidof portmap`" ] && echo "Error: portmap isn't running" && exit 0
+fi
+
+# Sanity checks
+[ -x /usr/sbin/rpc.nfsd ] || exit 0
+[ -x /usr/sbin/rpc.mountd ] || exit 0
[ -f /etc/exports ] || exit 0
-# Source networking configuration
-if [ -f /etc/sysconfig/nfs ]; then
- . /etc/sysconfig/nfs
-fi
# See how we were called.
case "$1" in
start)
# Start daemons.
- show Starting rpc.mountd
- daemon rpc.mountd
- show Starting rpc.nfsd
- daemon rpc.nfsd
+ if [ "$NFSDTYPE" = "U" ] ; then
+ msg_starting "NFS mountd"
+ daemon rpc.mountd
+ msg_starting "NFS daemon"
+ daemon rpc.nfsd
+ else
+ msg_starting "NFS"
+ daemon /usr/sbin/exportfs -r
+ msg_starting "NFS mountd"
+ daemon rpc.mountd $RPCMOUNTDOPTS
+ msg_starting "NFS daemon"
+ daemon rpc.nfsd $RPCNFSDCOUNT
+ fi
touch /var/lock/subsys/nfs
;;
stop)
# Stop daemons.
- show Shutting down rpc.mountd
- killproc rpc.mountd
- show Shutting down rpc.nfsd
- killproc rpc.nfsd
+ if [ "$NFSDTYPE" = "U" ] ; then
+ msg_stopping "NFS mountd"
+ killproc rpc.mountd
+ msg_stopping "NFS daemon"
+ killproc rpc.nfsd
+ else
+ msg_stopping "NFS mountd"
+ killproc rpc.mountd
+ msg_stopping "NFS daemon"
+ killproc nfsd -QUIT
+ msg_stopping "NFS"
+ daemon /usr/sbin/exportfs -au
+ fi
rm -f /var/lock/subsys/nfs
;;
status)
status rpc.mountd
- status rpc.nfsd
+ if [ "$NFSDTYPE" = "U" ] ; then
+ status rpc.nfsd
+ else
+ status nfsd
+ fi
;;
restart)
- $0 stop
- $0 start
+ if [ "$NFSDTYPE" = "U" ] ; then
+ $0 stop
+ $0 start
+ else
+ show "Restarting NFS services (killing)"
+ killproc rpc.mountd
+ show "Restarting NFS services (starting)"
+ daemon rpc.mountd $RPCMOUNTDOPTS
+ /usr/sbin/exportfs -r
+ touch /var/lock/subsys/nfs
+ fi
+ ;;
+ reload)
+ [ "$NFSDTYPE" = "U" ] && exit 0
+ /usr/sbin/exportfs
+ touch /var/lock/subsys/nfs
+ ;;
+ probe)
+ [ "$NFSDTYPE" = "U" ] && exit 0
+ if [ ! -f /var/lock/subsys/nfs ] ; then
+ echo start; exit 0
+ fi
+ /sbin/pidof rpc.mountd >/dev/null 2>&1; MOUNTD="$?"
+ /sbin/pidof nfsd >/dev/null 2>&1; NFSD="$?"
+ if [ $MOUNTD = 1 -o $NFSD = 1 ] ; then
+ echo restart; exit 0
+ fi
+ if [ /etc/exports -nt /var/lock/subsys/nfs ] ; then
+ echo reload; exit 0
+ fi
;;
*)
- echo "Usage: $0 {start|stop|status|restart}"
+ msg_Usage "$0 {start|stop|status|restart|reload|probe}"
exit 1
esac
exit 0
-