2004-09-09 09:14:13 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# nfs This shell script takes care of starting and stopping
|
|
|
|
# the NFS services.
|
|
|
|
#
|
2009-11-03 13:52:20 +00:00
|
|
|
# chkconfig: - 30 60
|
2009-06-10 16:14:13 +00:00
|
|
|
# description: NFS is a popular protocol for file sharing across networks.
|
|
|
|
# This service provides NFS server functionality, which is \
|
|
|
|
# configured via the /etc/exports file.
|
2004-09-09 09:14:13 +00:00
|
|
|
# probe: true
|
2004-09-09 09:19:15 +00:00
|
|
|
# config: /etc/sysconfig/nfs
|
2004-09-09 09:14:13 +00:00
|
|
|
|
2009-06-10 16:14:13 +00:00
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Provides: nfs
|
|
|
|
# Required-Start: $local_fs $network $syslog
|
|
|
|
# Required-Stop: $local_fs $network $syslog
|
|
|
|
# Default-Stop: 0 1 6
|
|
|
|
# Short-Description: Start up the NFS server sevice
|
|
|
|
# Description: NFS is a popular protocol for file sharing across networks \
|
|
|
|
# This service provides NFS server functionality, \
|
|
|
|
# which is configured via the /etc/exports file.
|
|
|
|
### END INIT INFO
|
|
|
|
|
|
|
|
|
2004-09-09 09:14:13 +00:00
|
|
|
# Source function library.
|
|
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
|
|
|
|
# Source networking configuration.
|
2008-09-16 20:29:11 +00:00
|
|
|
[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
|
2004-09-09 09:14:13 +00:00
|
|
|
|
2008-12-01 14:19:25 +00:00
|
|
|
# Check for and source configuration file otherwise set defaults
|
|
|
|
[ -f /etc/sysconfig/nfs ] && . /etc/sysconfig/nfs
|
|
|
|
|
|
|
|
# Remote quota server
|
|
|
|
[ -z "$RQUOTAD" ] && RQUOTAD=`type -path rpc.rquotad`
|
|
|
|
|
2008-09-16 20:29:11 +00:00
|
|
|
RETVAL=0
|
2004-09-09 09:14:13 +00:00
|
|
|
|
2008-09-16 20:29:11 +00:00
|
|
|
# See how we were called.
|
|
|
|
case "$1" in
|
|
|
|
start)
|
2004-09-09 09:14:13 +00:00
|
|
|
|
2008-09-16 20:29:11 +00:00
|
|
|
# Check that networking is up.
|
|
|
|
[ "${NETWORKING}" != "yes" ] && exit 6
|
2004-09-09 09:16:38 +00:00
|
|
|
|
2008-09-16 20:29:11 +00:00
|
|
|
[ -x /usr/sbin/rpc.nfsd ] || exit 5
|
|
|
|
[ -x /usr/sbin/rpc.mountd ] || exit 5
|
|
|
|
[ -x /usr/sbin/exportfs ] || exit 5
|
2004-09-09 09:14:13 +00:00
|
|
|
|
2008-09-16 20:29:11 +00:00
|
|
|
# Make sure the rpc.mountd is not already running.
|
|
|
|
if status rpc.mountd > /dev/null ; then
|
|
|
|
exit 0
|
|
|
|
fi
|
2004-09-09 09:19:15 +00:00
|
|
|
|
2008-09-16 20:29:11 +00:00
|
|
|
# Don't fail if /etc/exports doesn't exist; create a bare-bones
|
|
|
|
# version and continue.
|
|
|
|
[ -r /etc/exports ] || \
|
|
|
|
{ touch /etc/exports && chmod u+rw,g+r,o+r /etc/exports ; } || \
|
|
|
|
{ echo "/etc/exports does not exist" ; exit 0 ; }
|
2004-09-09 09:19:15 +00:00
|
|
|
|
2008-09-16 20:29:11 +00:00
|
|
|
[ -z "$MOUNTD_NFS_V2" ] && MOUNTD_NFS_V2=default
|
|
|
|
[ -z "$MOUNTD_NFS_V3" ] && MOUNTD_NFS_V3=default
|
2004-09-09 09:19:15 +00:00
|
|
|
|
2008-09-16 20:29:11 +00:00
|
|
|
# Number of servers to be started by default
|
|
|
|
[ -z "$RPCNFSDCOUNT" ] && RPCNFSDCOUNT=8
|
|
|
|
|
2004-09-09 09:14:13 +00:00
|
|
|
# Start daemons.
|
2005-02-14 19:29:31 +00:00
|
|
|
[ -x /usr/sbin/rpc.svcgssd ] && /sbin/service rpcsvcgssd start
|
|
|
|
|
2009-03-06 12:31:06 +00:00
|
|
|
# Set the ports lockd should listen on
|
|
|
|
if [ -n "$LOCKD_TCPPORT" -o -n "$LOCKD_UDPPORT" ]; then
|
|
|
|
[ -x /sbin/modprobe ] && /sbin/modprobe lockd $LOCKDARG
|
|
|
|
[ -n "$LOCKD_TCPPORT" ] && \
|
|
|
|
/sbin/sysctl -w fs.nfs.nlm_tcpport=$LOCKD_TCPPORT >/dev/null 2>&1
|
|
|
|
[ -n "$LOCKD_UDPPORT" ] && \
|
|
|
|
/sbin/sysctl -w fs.nfs.nlm_udpport=$LOCKD_UDPPORT >/dev/null 2>&1
|
|
|
|
fi
|
|
|
|
|
2008-12-01 13:31:39 +00:00
|
|
|
# Load the nfsd module so /proc/fs/nfsd will exist
|
|
|
|
[ "$NFSD_MODULE" != "noload" ] && {
|
|
|
|
[ -x /sbin/modprobe ] && /sbin/modprobe nfsd
|
|
|
|
}
|
2004-09-09 09:23:36 +00:00
|
|
|
action $"Starting NFS services: " /usr/sbin/exportfs -r
|
2004-09-09 09:21:05 +00:00
|
|
|
|
2004-09-09 09:19:15 +00:00
|
|
|
if [ -n "$RQUOTAD" -a "$RQUOTAD" != "no" ]; then
|
2004-09-09 09:21:05 +00:00
|
|
|
echo -n $"Starting NFS quotas: "
|
2004-10-14 13:53:24 +00:00
|
|
|
[ -n "$RQUOTAD_PORT" ] \
|
|
|
|
&& RPCRQUOTADOPTS="$RPCRQUOTADOPTS -p $RQUOTAD_PORT"
|
|
|
|
daemon rpc.rquotad $RPCRQUOTADOPTS
|
2007-05-16 17:34:55 +00:00
|
|
|
RETVAL=$?
|
2004-09-09 09:16:23 +00:00
|
|
|
echo
|
|
|
|
fi
|
2008-09-18 11:49:19 +00:00
|
|
|
|
2004-09-09 09:19:09 +00:00
|
|
|
echo -n $"Starting NFS daemon: "
|
2005-09-23 13:48:25 +00:00
|
|
|
daemon rpc.nfsd $RPCNFSDARGS $RPCNFSDCOUNT
|
2007-05-16 17:34:55 +00:00
|
|
|
RETVAL=$?
|
2004-09-09 09:19:09 +00:00
|
|
|
echo
|
2007-05-16 17:34:55 +00:00
|
|
|
[ $RETVAL -ne 0 ] && exit $RETVAL
|
2004-09-09 09:19:15 +00:00
|
|
|
|
|
|
|
[ -n "$MOUNTD_PORT" ] \
|
|
|
|
&& RPCMOUNTDOPTS="$RPCMOUNTDOPTS -p $MOUNTD_PORT"
|
|
|
|
|
2006-06-30 14:17:52 +00:00
|
|
|
case $MOUNTD_NFS_V1 in
|
|
|
|
no|NO)
|
|
|
|
RPCMOUNTDOPTS="$RPCMOUNTDOPTS --no-nfs-version 1" ;;
|
|
|
|
esac
|
|
|
|
|
2004-09-09 09:19:15 +00:00
|
|
|
case $MOUNTD_NFS_V2 in
|
|
|
|
no|NO)
|
2004-09-09 09:25:09 +00:00
|
|
|
RPCMOUNTDOPTS="$RPCMOUNTDOPTS --no-nfs-version 2" ;;
|
2004-09-09 09:19:15 +00:00
|
|
|
esac
|
|
|
|
|
|
|
|
case $MOUNTD_NFS_V3 in
|
|
|
|
no|NO)
|
2004-09-09 09:25:09 +00:00
|
|
|
RPCMOUNTDOPTS="$RPCMOUNTDOPTS --no-nfs-version 3" ;;
|
2004-09-09 09:19:15 +00:00
|
|
|
esac
|
|
|
|
|
|
|
|
echo -n $"Starting NFS mountd: "
|
|
|
|
daemon rpc.mountd $RPCMOUNTDOPTS
|
2007-05-16 17:34:55 +00:00
|
|
|
RETVAL=$?
|
2004-09-09 09:19:15 +00:00
|
|
|
echo
|
2004-09-09 09:14:13 +00:00
|
|
|
touch /var/lock/subsys/nfs
|
2004-09-09 09:23:36 +00:00
|
|
|
|
2005-02-14 19:29:31 +00:00
|
|
|
# Let rpc.idmapd know that rpc.mountd just started
|
2004-09-09 09:23:36 +00:00
|
|
|
[ -x /usr/sbin/rpc.idmapd ] && /sbin/service rpcidmapd condstart
|
|
|
|
|
2004-09-09 09:14:13 +00:00
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
# Stop daemons.
|
2004-09-09 09:19:15 +00:00
|
|
|
echo -n $"Shutting down NFS mountd: "
|
2004-09-09 09:14:13 +00:00
|
|
|
killproc rpc.mountd
|
|
|
|
echo
|
2004-09-09 09:19:15 +00:00
|
|
|
echo -n $"Shutting down NFS daemon: "
|
2007-05-10 15:28:48 +00:00
|
|
|
killproc nfsd -2
|
2004-09-09 09:14:13 +00:00
|
|
|
echo
|
2004-10-17 15:27:00 +00:00
|
|
|
if [ -n "$RQUOTAD" -a "$RQUOTAD" != "no" ]; then
|
2004-09-09 09:21:05 +00:00
|
|
|
echo -n $"Shutting down NFS quotas: "
|
2004-09-09 09:19:15 +00:00
|
|
|
killproc rpc.rquotad
|
2007-07-30 10:10:07 +00:00
|
|
|
RETVAL=$?
|
2004-09-09 09:19:15 +00:00
|
|
|
echo
|
2004-09-09 09:16:23 +00:00
|
|
|
fi
|
2004-09-09 09:21:05 +00:00
|
|
|
# Reset the lockd ports if they were set
|
2004-09-09 09:23:36 +00:00
|
|
|
if [ -n "$LOCKD_TCPPORT" ]; then
|
2004-09-09 09:21:05 +00:00
|
|
|
/sbin/sysctl -w fs.nfs.nlm_tcpport=0 >/dev/null 2>&1
|
|
|
|
fi
|
2004-09-09 09:23:36 +00:00
|
|
|
if [ -n "$LOCKD_UDPPORT" ]; then
|
2004-09-09 09:21:05 +00:00
|
|
|
/sbin/sysctl -w fs.nfs.nlm_udpport=0 >/dev/null 2>&1
|
|
|
|
fi
|
2004-09-09 09:19:15 +00:00
|
|
|
# Do it the last so that clients can still access the server
|
|
|
|
# when the server is running.
|
2007-05-16 17:34:55 +00:00
|
|
|
cnt=`/usr/sbin/exportfs -v | /usr/bin/wc -l`
|
|
|
|
if [ $cnt -gt 0 ]; then
|
|
|
|
action $"Shutting down NFS services: " /usr/sbin/exportfs -au
|
|
|
|
else
|
|
|
|
action $"Shutting down NFS services: " /bin/false
|
|
|
|
fi
|
2007-07-30 10:10:07 +00:00
|
|
|
[ -x /usr/sbin/rpc.svcgssd ] && /sbin/service rpcsvcgssd stop
|
2004-09-09 09:14:13 +00:00
|
|
|
rm -f /var/lock/subsys/nfs
|
|
|
|
;;
|
|
|
|
status)
|
2005-02-14 19:29:31 +00:00
|
|
|
[ -x /usr/sbin/rpc.svcgssd ] && /sbin/service rpcsvcgssd status
|
2004-09-09 09:14:13 +00:00
|
|
|
status rpc.mountd
|
|
|
|
status nfsd
|
2004-10-17 15:27:00 +00:00
|
|
|
if [ -n "$RQUOTAD" -a "$RQUOTAD" != "no" ]; then
|
2004-09-09 09:19:15 +00:00
|
|
|
status rpc.rquotad
|
2004-09-09 09:16:23 +00:00
|
|
|
fi
|
2007-05-16 17:34:55 +00:00
|
|
|
RETVAL=$?
|
2004-09-09 09:14:13 +00:00
|
|
|
;;
|
|
|
|
restart)
|
2004-09-09 09:19:15 +00:00
|
|
|
$0 stop
|
|
|
|
$0 start
|
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
|
2004-09-09 09:19:15 +00:00
|
|
|
echo $"start"; exit 0
|
2004-09-09 09:14:13 +00:00
|
|
|
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
|
2004-09-09 09:19:15 +00:00
|
|
|
echo $"restart"; exit 0
|
2004-09-09 09:14:13 +00:00
|
|
|
fi
|
|
|
|
if [ /etc/exports -nt /var/lock/subsys/nfs ] ; then
|
2004-09-09 09:19:15 +00:00
|
|
|
echo $"reload"; exit 0
|
2004-09-09 09:14:13 +00:00
|
|
|
fi
|
|
|
|
;;
|
2004-09-09 09:21:05 +00:00
|
|
|
condrestart)
|
2005-02-14 19:29:31 +00:00
|
|
|
[ -x /usr/sbin/rpc.svcgssd ] && /sbin/service rpcsvcgssd condrestart
|
2004-09-09 09:21:05 +00:00
|
|
|
[ -f /var/lock/subsys/nfs ] && {
|
|
|
|
$0 stop
|
|
|
|
$0 start
|
2008-07-02 23:35:53 +00:00
|
|
|
RETVAL=$?
|
|
|
|
}
|
|
|
|
;;
|
|
|
|
condstop)
|
|
|
|
[ -x /usr/sbin/rpc.svcgssd ] && /sbin/service rpcsvcgssd condstop
|
|
|
|
[ -f /var/lock/subsys/nfs ] && {
|
|
|
|
$0 stop
|
|
|
|
RETVAL=$?
|
2004-09-09 09:21:05 +00:00
|
|
|
}
|
|
|
|
;;
|
2004-09-09 09:14:13 +00:00
|
|
|
*)
|
2008-07-02 23:35:53 +00:00
|
|
|
echo $"Usage: nfs {start|stop|status|restart|reload|condrestart|condstop}"
|
2007-07-30 10:10:07 +00:00
|
|
|
RETVAL=3
|
|
|
|
;;
|
2004-09-09 09:14:13 +00:00
|
|
|
esac
|
|
|
|
|
2007-07-30 10:10:07 +00:00
|
|
|
exit $RETVAL
|