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 # Check that networking is up.
23 if is_yes "${NETWORKING}"; then
24 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
25 msg_network_down "NFS daemon"
32 if [ "$1" != "stop" ]; then
33 check_portmapper || { nls "Error: portmap isn't running" && exit 0; }
37 # Check if the service is already running?
38 if [ -f /var/lock/subsys/nfs ]; then
39 msg_already_running "NFS daemon"
43 if ! grep -q nfsd /proc/mounts ; then
44 modprobe -s nfsd > /dev/null 2>&1
45 run_cmd "Mounting /proc/fs/nfsd filesystem" mount -t nfsd nfsd /proc/fs/nfsd
48 # Set the ports lockd should listen on
49 if [ -n "$LOCKD_TCPPORT" ]; then
50 /sbin/sysctl -w fs.nfs.nlm_tcpport=$LOCKD_TCPPORT >/dev/null 2>&1
52 if [ -n "$LOCKD_UDPPORT" ]; then
53 /sbin/sysctl -w fs.nfs.nlm_udpport=$LOCKD_UDPPORT >/dev/null 2>&1
57 msg_starting "NFS exportfs"
58 daemon /usr/sbin/exportfs -r
59 msg_starting "NFS mountd"
60 daemon /usr/sbin/rpc.mountd $RPCMOUNTDOPTIONS
61 msg_starting "NFS daemon"
62 daemon /usr/sbin/rpc.nfsd $RPCNFSDCOUNT
63 touch /var/lock/subsys/nfs
67 if [ ! -f /var/lock/subsys/nfs ]; then
73 msg_stopping "NFS daemon"
75 msg_stopping "NFS mountd"
77 msg_stopping "NFS exportfs"
78 daemon /usr/sbin/exportfs -au
79 rm -f /var/lock/subsys/nfs
83 # See how we were called.
94 /sbin/service idmapd status >/dev/null && /sbin/service idmapd reload
95 /sbin/service svcgssd status >/dev/null && /sbin/service svcgssd restart
98 if [ -f /var/lock/subsys/nfs ]; then
101 /usr/sbin/exportfs -r
102 [ $? -ne 0 ] && RETVAL=7
103 if [ $RETVAL -eq 0 ]; then
105 /sbin/service idmapd status >/dev/null && /sbin/service idmapd reload
106 /sbin/service svcgssd status >/dev/null && /sbin/service svcgssd restart
111 msg_not_running "NFS"
116 if [ ! -f /var/lock/subsys/nfs ]; then
120 /sbin/pidof rpc.mountd >/dev/null 2>&1; MOUNTD="$?"
121 /sbin/pidof nfsd >/dev/null 2>&1; NFSD="$?"
122 if [ $MOUNTD = 1 -o $NFSD = 1 ]; then
126 if [ /etc/exports -nt /var/lock/subsys/nfs ]; then
132 echo "Configured NFS exports:"
133 grep -v "^#" /etc/exports
135 echo "Active NFS exports:"
136 /usr/sbin/exportfs -v
142 [ $RETVAL -eq 0 ] && RETVAL=$RET
145 msg_usage "$0 {start|stop|restart|reload|force-reload|probe|status}"