2004-09-09 09:14:13 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# nfs This shell script takes care of starting and stopping
|
|
|
|
# the NFS services.
|
|
|
|
#
|
|
|
|
# chkconfig: - 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.
|
|
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
|
|
|
|
# Source networking configuration.
|
|
|
|
if [ ! -f /etc/sysconfig/network ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
. /etc/sysconfig/network
|
|
|
|
|
|
|
|
# Check that networking is up.
|
|
|
|
[ ${NETWORKING} = "no" ] && exit 0
|
|
|
|
|
|
|
|
[ -x /usr/sbin/rpc.nfsd ] || exit 0
|
|
|
|
[ -x /usr/sbin/rpc.mountd ] || exit 0
|
|
|
|
[ -x /usr/sbin/exportfs ] || exit 0
|
|
|
|
[ -s /etc/exports ] || exit 0
|
|
|
|
|
2004-09-09 09:14:35 +00:00
|
|
|
# Number of servers to be started by default
|
2004-09-09 09:14:13 +00:00
|
|
|
RPCNFSDCOUNT=8
|
2004-09-09 09:14:35 +00:00
|
|
|
|
|
|
|
# NFSv3 only if kernel >= 2.2.18
|
|
|
|
OS_RELEASE=`uname --release`
|
|
|
|
OS_RELEASE_MINOR=`echo "$OS_RELEASE" | sed 's/\(^[0-9]\)\.\([0-9]*\).*/\2/'`
|
|
|
|
OS_RELEASE_VERSION=`echo "$OS_RELEASE" | sed 's/\(^[0-9]\)\.\([0-9]*\)\.\([0-9]*\).*/\3/'`
|
|
|
|
if [ "$OS_RELEASE_MINOR" -gt 2 ]; then
|
|
|
|
RPCMOUNTDOPTS=
|
|
|
|
elif [ "$OS_RELEASE_MINOR" -eq 2 -a "$OS_RELEASE_VERSION" -ge 18 ]; then
|
|
|
|
RPCMOUNTDOPTS=
|
|
|
|
else
|
|
|
|
RPCMOUNTDOPTS="--no-nfs-version 3"
|
|
|
|
fi
|
2004-09-09 09:14:13 +00:00
|
|
|
|
2004-09-09 09:16:23 +00:00
|
|
|
if [ -n "$MOUNTD_PORT" ]; then
|
|
|
|
RPCMOUNDOPTS="$RPCMOUNTDOPTS --port $MOUNTD_PORT"
|
|
|
|
fi
|
|
|
|
|
2004-09-09 09:14:13 +00:00
|
|
|
# See how we were called.
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
# Start daemons.
|
2004-09-09 09:16:23 +00:00
|
|
|
action "Starting NFS services: " /usr/sbin/exportfs -r
|
|
|
|
if [ -x /usr/sbin/rpc.rquotad ] ; then
|
|
|
|
echo -n "Starting NFS quotas: "
|
|
|
|
daemon rpc.rquotad
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
echo -n "Starting NFS mountd: "
|
2004-09-09 09:14:13 +00:00
|
|
|
daemon rpc.mountd $RPCMOUNTDOPTS
|
|
|
|
echo
|
2004-09-09 09:16:23 +00:00
|
|
|
echo -n "Starting NFS daemon: "
|
2004-09-09 09:14:13 +00:00
|
|
|
daemon rpc.nfsd $RPCNFSDCOUNT
|
|
|
|
echo
|
|
|
|
touch /var/lock/subsys/nfs
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
# Stop daemons.
|
2004-09-09 09:16:23 +00:00
|
|
|
echo -n "Shutting down NFS mountd: "
|
2004-09-09 09:14:13 +00:00
|
|
|
killproc rpc.mountd
|
|
|
|
echo
|
2004-09-09 09:16:23 +00:00
|
|
|
echo -n "Shutting down NFS daemon: "
|
2004-09-09 09:14:13 +00:00
|
|
|
killproc nfsd
|
|
|
|
echo
|
2004-09-09 09:16:23 +00:00
|
|
|
action "Shutting down NFS services: " /usr/sbin/exportfs -au
|
|
|
|
if [ -x /usr/sbin/rpc.rquotad ] ; then
|
|
|
|
echo -n "Shutting down NFS quotas: "
|
|
|
|
killproc rpc.rquotad
|
|
|
|
echo
|
|
|
|
fi
|
2004-09-09 09:14:13 +00:00
|
|
|
rm -f /var/lock/subsys/nfs
|
|
|
|
;;
|
|
|
|
status)
|
|
|
|
status rpc.mountd
|
|
|
|
status nfsd
|
2004-09-09 09:16:23 +00:00
|
|
|
if [ -x /usr/sbin/rpc.rquotad ] ; then
|
|
|
|
status rpc.rquotad
|
|
|
|
fi
|
2004-09-09 09:14:13 +00:00
|
|
|
;;
|
|
|
|
restart)
|
2004-09-09 09:16:23 +00:00
|
|
|
echo -n "Restarting NFS services: "
|
|
|
|
echo -n "rpc.mountd "
|
2004-09-09 09:14:13 +00:00
|
|
|
killproc rpc.mountd
|
|
|
|
daemon rpc.mountd $RPCMOUNTDOPTS
|
|
|
|
/usr/sbin/exportfs -r
|
|
|
|
touch /var/lock/subsys/nfs
|
2004-09-09 09:14:20 +00:00
|
|
|
echo
|
2004-09-09 09:14:13 +00:00
|
|
|
;;
|
|
|
|
reload)
|
|
|
|
/usr/sbin/exportfs -r
|
|
|
|
touch /var/lock/subsys/nfs
|
|
|
|
;;
|
|
|
|
probe)
|
|
|
|
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
|
|
|
|
;;
|
|
|
|
*)
|
2004-09-09 09:16:23 +00:00
|
|
|
echo "Usage: $0 {start|stop|status|restart|reload}"
|
2004-09-09 09:14:13 +00:00
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
|