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.
12 # Source function library
13 . /etc/rc.d/init.d/functions
16 . /etc/sysconfig/network
19 [ -f /etc/sysconfig/nfslock ] && . /etc/sysconfig/nfslock
20 [ -f /etc/sysconfig/nfsd ] && . /etc/sysconfig/nfsd
22 [ -n "$NFSv1" ] || NFSv1="yes"
23 [ -n "$NFSv2" ] || NFSv2="yes"
24 [ -n "$NFSv3" ] || NFSv3="yes"
25 [ -n "$NFSv4" ] || NFSv4="yes"
27 # Check that networking is up.
28 if is_yes "${NETWORKING}"; then
29 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
30 msg_network_down "NFS daemon"
37 if [ -x /sbin/pidof ] && [ "$1" != "stop" ]; then
38 [ -z "`/sbin/pidof portmap`" ] && nls "Error: portmap isn't running" && exit 0
42 # Check if the service is already running?
43 if [ ! -f /var/lock/subsys/nfs ]; then
44 if ! grep -q nfsd /proc/mounts ; then
45 modprobe -s nfsd > /dev/null 2>&1
46 run_cmd "Mounting /proc/fs/nfsd filesystem" mount -t nfsd nfsd /proc/fs/nfsd
49 # Set the ports lockd should listen on
50 if [ -n "$LOCKD_TCPPORT" ]; then
51 /sbin/sysctl -w fs.nfs.nlm_tcpport=$LOCKD_TCPPORT >/dev/null 2>&1
53 if [ -n "$LOCKD_UDPPORT" ]; then
54 /sbin/sysctl -w fs.nfs.nlm_udpport=$LOCKD_UDPPORT >/dev/null 2>&1
57 for vers in 1 2 3 4 ; do
58 is_yes $(eval echo \$NFSv$vers) || \
59 RPCMOUNTOPTIONS="$RPCMOUNTOPTIONS --no-nfs-version $vers"
62 [ -n "$MOUNTD_PORT" ] && RPCMOUNTOPTIONS="$RPCMOUNTOPTIONS -p $MOUNTD_PORT"
65 msg_starting "NFS exportfs"
66 daemon /usr/sbin/exportfs -r
67 msg_starting "NFS mountd"
68 daemon rpc.mountd $RPCMOUNTOPTIONS
69 msg_starting "NFS daemon"
70 daemon rpc.nfsd $RPCNFSDCOUNT
71 touch /var/lock/subsys/nfs
73 msg_already_running "NFS daemon"
78 if [ -f /var/lock/subsys/nfs ]; then
80 msg_stopping "NFS daemon"
82 msg_stopping "NFS mountd"
85 daemon /usr/sbin/exportfs -au
86 rm -f /var/lock/subsys/nfs
93 # See how we were called.
104 /sbin/service idmapd status >/dev/null && /sbin/service idmapd reload
105 /sbin/service svcgssd status >/dev/null && /sbin/service svcgssd restart
108 if [ -f /var/lock/subsys/nfs ]; then
111 /usr/sbin/exportfs -r
112 [ $? -ne 0 ] && RETVAL=7
113 if [ $RETVAL -eq 0 ]; then
115 /sbin/service idmapd status >/dev/null && /sbin/service idmapd reload
116 /sbin/service svcgssd status >/dev/null && /sbin/service svcgssd restart
121 msg_not_running "NFS"
126 if [ ! -f /var/lock/subsys/nfs ]; then
130 /sbin/pidof rpc.mountd >/dev/null 2>&1; MOUNTD="$?"
131 /sbin/pidof nfsd >/dev/null 2>&1; NFSD="$?"
132 if [ $MOUNTD = 1 -o $NFSD = 1 ]; then
136 if [ /etc/exports -nt /var/lock/subsys/nfs ]; then
142 echo "Configured NFS exports:"
143 grep -v "^#" /etc/exports
145 echo "Active NFS exports:"
146 /usr/sbin/exportfs -v
152 [ $RETVAL -eq 0 ] && RETVAL=$RET
155 msg_usage "$0 {start|stop|restart|reload|force-reload|probe|status}"