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/nfsd ] && . /etc/sysconfig/nfsd
21 # Check that networking is up.
22 if is_yes "${NETWORKING}"; then
23 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
24 msg_network_down "NFS daemon"
32 # Check if the service is already running?
33 if [ ! -f /var/lock/subsys/nfs ]; then
34 if [ -x /sbin/pidof ]; then
35 if [ -z "`/sbin/pidof portmap`" ]; then
36 nls "Error: portmap isn't running"
41 if ! is_yes "$NFS4" ; then
42 RPCMOUNTOPTIONS="$RPCMOUNTOPTIONS --no-nfs-version 4"
46 modprobe -s nfsd > /dev/null 2>&1
47 if [ "$(kernelverser)" -ge "002006" ]; then
48 grep -q nfsd /proc/filesystems && \
49 ! grep -q nfsd /proc/mounts && \
50 run_cmd "Mounting /proc/fs/nfsd filesystem" mount -t nfsd nfsd /proc/fs/nfsd
52 msg_starting "NFS exportfs"
53 daemon /usr/sbin/exportfs -r
54 msg_starting "NFS mountd"
55 daemon rpc.mountd $RPCMOUNTOPTIONS
56 if is_yes "$NFS4" ; then
57 if (grep -q rpc_pipefs /proc/filesystems); then
58 ! grep -q rpc_pipefs /proc/mounts && \
59 run_cmd "Mounting /var/lib/nfs/rpc_pipefs filesystem" mount -t rpc_pipefs rpc_pipefs /var/lib/nfs/rpc_pipefs
60 if [ ! -f /var/lock/subsys/idmapd ]; then
61 msg_starting "NFS idmapd"
62 daemon rpc.idmapd $RPCIDMAPOPTIONS
63 [ $? = 0 ] && touch /var/lock/subsys/idmapd
65 msg_starting "NFS svcgssd"
66 daemon rpc.svcgssd $RPCSVCGSSOPTIONS
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 mountd"
82 msg_stopping "NFS daemon"
84 if is_yes "$NFS4" ; then
85 if (grep -q rpc_pipefs /proc/filesystems); then
86 msg_stopping "NFS svcgssd"
88 if [ -f /var/lock/subsys/idmapd -a ! -f /var/lock/subsys/nfsfs ]; then
89 msg_stopping "NFS idmapd"
91 rm -f /var/lock/subsys/idmapd
96 daemon /usr/sbin/exportfs -au
97 rm -f /var/lock/subsys/nfs
104 # See how we were called.
117 if [ -f /var/lock/subsys/nfs ]; then
121 [ $? -ne 0 ] && RETVAL=7
122 [ $RETVAL -eq 0 ] && ok || died
124 msg_not_running "NFS"
129 if [ ! -f /var/lock/subsys/nfs ]; then
133 /sbin/pidof rpc.mountd >/dev/null 2>&1; MOUNTD="$?"
134 /sbin/pidof nfsd >/dev/null 2>&1; NFSD="$?"
135 if [ $MOUNTD = 1 -o $NFSD = 1 ]; then
139 if [ /etc/exports -nt /var/lock/subsys/nfs ]; then
149 [ $RETVAL -eq 0 ] && RETVAL=$RET
152 msg_usage "$0 {start|stop|restart|reload|force-reload|probe|status}"