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 "$NFSv2" ] || NFSv2="yes"
23 [ -n "$NFSv3" ] || NFSv3="yes"
24 [ -n "$NFSv4" ] || NFSv4="yes"
26 # Check that networking is up.
27 if is_yes "${NETWORKING}"; then
28 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
29 msg_network_down "NFS daemon"
36 if [ "$1" != "stop" ]; then
37 check_portmapper || { nls "Error: portmap isn't running" && exit 0; }
41 # Check if the service is already running?
42 if [ -f /var/lock/subsys/nfs ]; then
43 msg_already_running "NFS daemon"
47 if ! grep -q nfsd /proc/mounts ; then
48 modprobe -s nfsd > /dev/null 2>&1
49 run_cmd "Mounting /proc/fs/nfsd filesystem" mount -t nfsd nfsd /proc/fs/nfsd
52 # Set the ports lockd should listen on
53 if [ -n "$LOCKD_TCPPORT" ]; then
54 /sbin/sysctl -w fs.nfs.nlm_tcpport=$LOCKD_TCPPORT >/dev/null 2>&1
56 if [ -n "$LOCKD_UDPPORT" ]; then
57 /sbin/sysctl -w fs.nfs.nlm_udpport=$LOCKD_UDPPORT >/dev/null 2>&1
60 for vers in 2 3 4 ; do
61 is_yes $(eval echo \$NFSv$vers) || \
62 RPCMOUNTOPTIONS="$RPCMOUNTOPTIONS --no-nfs-version $vers"
65 [ -n "$MOUNTD_PORT" ] && RPCMOUNTOPTIONS="$RPCMOUNTOPTIONS -p $MOUNTD_PORT"
68 msg_starting "NFS exportfs"
69 daemon /usr/sbin/exportfs -r
70 msg_starting "NFS mountd"
71 daemon /usr/sbin/rpc.mountd $RPCMOUNTOPTIONS
72 msg_starting "NFS daemon"
73 daemon /usr/sbin/rpc.nfsd $RPCNFSDCOUNT
74 touch /var/lock/subsys/nfs
78 if [ ! -f /var/lock/subsys/nfs ]; then
84 msg_stopping "NFS daemon"
86 msg_stopping "NFS mountd"
88 msg_stopping "NFS exportfs"
89 daemon /usr/sbin/exportfs -au
90 rm -f /var/lock/subsys/nfs
94 # See how we were called.
105 /sbin/service idmapd status >/dev/null && /sbin/service idmapd reload
106 /sbin/service svcgssd status >/dev/null && /sbin/service svcgssd restart
109 if [ -f /var/lock/subsys/nfs ]; then
112 /usr/sbin/exportfs -r
113 [ $? -ne 0 ] && RETVAL=7
114 if [ $RETVAL -eq 0 ]; then
116 /sbin/service idmapd status >/dev/null && /sbin/service idmapd reload
117 /sbin/service svcgssd status >/dev/null && /sbin/service svcgssd restart
122 msg_not_running "NFS"
127 if [ ! -f /var/lock/subsys/nfs ]; then
131 /sbin/pidof rpc.mountd >/dev/null 2>&1; MOUNTD="$?"
132 /sbin/pidof nfsd >/dev/null 2>&1; NFSD="$?"
133 if [ $MOUNTD = 1 -o $NFSD = 1 ]; then
137 if [ /etc/exports -nt /var/lock/subsys/nfs ]; then
143 echo "Configured NFS exports:"
144 grep -v "^#" /etc/exports
146 echo "Active NFS exports:"
147 /usr/sbin/exportfs -v
153 [ $RETVAL -eq 0 ] && RETVAL=$RET
156 msg_usage "$0 {start|stop|restart|reload|force-reload|probe|status}"