3 # nfs This shell script takes care of starting and stopping
7 # description: NFS is a popular protocol for file sharing across TCP/IP \
8 # networks. This service provides NFS server functionality, \
9 # which is configured via the /etc/exports file.
11 # config: /etc/sysconfig/nfs
13 # Source function library.
14 . /etc/rc.d/init.d/functions
16 # Source networking configuration.
17 if [ ! -f /etc/sysconfig/network ]; then
21 . /etc/sysconfig/network
23 # Check that networking is up.
24 [ ${NETWORKING} = "no" ] && exit 0
26 [ -x /usr/sbin/rpc.nfsd ] || exit 0
27 [ -x /usr/sbin/rpc.mountd ] || exit 0
28 [ -x /usr/sbin/exportfs ] || exit 0
29 [ -s /etc/exports ] || exit 0
31 # Check for and source configuration file otherwise set defaults
32 # TUNE_QUEUE: controls whether to up the size of input queues
33 [ -f /etc/sysconfig/nfs ] && . /etc/sysconfig/nfs
35 [ -z "$MOUNTD_NFS_V2" ] && MOUNTD_NFS_V2=auto
36 [ -z "$MOUNTD_NFS_V3" ] && MOUNTD_NFS_V3=auto
38 # Number of servers to be started by default
39 [ -z "$NFSDCOUNT" ] && NFSDCOUNT=8
42 [ -z "$RQUOTAD" ] && RQUOTAD=`type -path rpc.rquotad`
44 # Get the initial values for the input sock queues
45 # at the time of running the script.
46 if [ "$TUNE_QUEUE" = "yes" ]; then
47 RMEM_DEFAULT=`/sbin/sysctl -n net.core.rmem_default`
48 RMEM_MAX=`/sbin/sysctl -n net.core.rmem_max`
49 # 256kb recommended minimum size based on SPECsfs NFS benchmarks
50 [ -z "$NFS_QS" ] && NFS_QS=262144
53 # See how we were called.
57 # Apply input queue increase for nfs server
58 if [ "$TUNE_QUEUE" = "yes" ]; then
59 /sbin/sysctl -w net.core.rmem_default=$NFSD_QS >/dev/null 2>&1
60 /sbin/sysctl -w net.core.rmem_max=$NFSD_QS >/dev/null 2>&1
62 action "Starting NFS services: " /usr/sbin/exportfs -r
63 if [ -n "$RQUOTAD" -a "$RQUOTAD" != "no" ]; then
64 echo -n "Starting NFS quotas: "
68 echo -n "Starting NFS daemon: "
69 daemon rpc.nfsd $NFSDCOUNT
72 [ -n "$MOUNTD_PORT" ] \
73 && MOUNTD_OPTIONS="$MOUNTD_OPTIONS -p $MOUNTD_PORT"
74 [ "$MOUNTD_TCP" = "no" -o "$MOUNTD_TCP" = "NO" ] \
75 && MOUNTD_OPTIONS="$MOUNTD_OPTIONS --no-tcp"
77 case $MOUNTD_NFS_V2 in
79 # Let's see if we support NFS version 2.
80 /usr/sbin/rpcinfo -u localhost nfs 2 &>/dev/null
82 MOUNTD_OPTIONS="$MOUNTD_OPTIONS --no-nfs-version 2"
86 MOUNTD_OPTIONS="$MOUNTD_OPTIONS --no-nfs-version 2"
89 MOUNTD_OPTIONS="$MOUNTD_OPTIONS --nfs-version 2"
93 case $MOUNTD_NFS_V3 in
95 # Let's see if we support NFS version 3.
96 /usr/sbin/rpcinfo -u localhost nfs 3 &>/dev/null
98 MOUNTD_OPTIONS="$MOUNTD_OPTIONS --no-nfs-version 3"
102 MOUNTD_OPTIONS="$MOUNTD_OPTIONS --no-nfs-version 3"
105 MOUNTD_OPTIONS="$MOUNTD_OPTIONS --nfs-version 3"
109 echo -n "Starting NFS mountd: "
110 daemon rpc.mountd $MOUNTD_OPTIONS
112 touch /var/lock/subsys/nfs
113 # reset input queue for rest of network services
114 if [ "$TUNE_QUEUE" = "yes" ]; then
115 /sbin/sysctl -w net.core.rmem_default=$RMEM_DEFAULT >/dev/null 2>&1
116 /sbin/sysctl -w net.core.rmem_max=$RMEM_MAX >/dev/null 2>&1
121 echo -n "Shutting down NFS mountd: "
124 echo -n "Shutting down NFS daemon: "
127 if [ -n "$RQUOTAD" ]; then
128 echo -n "Shutting down NFS quotas: "
132 # Do it the last so that clients can still access the server
133 # when the server is running.
134 action "Shutting down NFS services: " /usr/sbin/exportfs -au
135 rm -f /var/lock/subsys/nfs
140 if [ -n "$RQUOTAD" ]; then
149 /usr/sbin/exportfs -r
150 touch /var/lock/subsys/nfs
153 if [ ! -f /var/lock/subsys/nfs ] ; then
156 /sbin/pidof rpc.mountd >/dev/null 2>&1; MOUNTD="$?"
157 /sbin/pidof nfsd >/dev/null 2>&1; NFSD="$?"
158 if [ $MOUNTD = 1 -o $NFSD = 1 ] ; then
161 if [ /etc/exports -nt /var/lock/subsys/nfs ] ; then
166 echo "Usage: nfs {start|stop|status|restart|reload}"