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 if [ ! -f /var/lock/subsys/svcgssd ]; then
66 msg_starting "NFS svcgssd"
67 daemon rpc.svcgssd $RPCSVCGSSOPTIONS
68 [ $? = 0 ] && touch /var/lock/subsys/svcgssd
72 msg_starting "NFS daemon"
73 daemon rpc.nfsd $RPCNFSDCOUNT
74 touch /var/lock/subsys/nfs
76 msg_already_running "NFS daemon"
81 if [ -f /var/lock/subsys/nfs ]; then
83 msg_stopping "NFS mountd"
85 msg_stopping "NFS daemon"
87 if is_yes "$NFS4" ; then
88 if (grep -q rpc_pipefs /proc/filesystems); then
89 if [ ! -f /var/lock/subsys/svcgssd ]; then
90 msg_stopping "NFS svcgssd"
92 rm -f /var/lock/subsys/svcgssd
94 if [ -f /var/lock/subsys/idmapd -a ! -f /var/lock/subsys/nfsfs ]; then
95 msg_stopping "NFS idmapd"
97 rm -f /var/lock/subsys/idmapd
102 daemon /usr/sbin/exportfs -au
103 rm -f /var/lock/subsys/nfs
105 msg_not_running "NFS"
110 # See how we were called.
123 if [ -f /var/lock/subsys/nfs ]; then
127 [ $? -ne 0 ] && RETVAL=7
128 [ $RETVAL -eq 0 ] && ok || died
130 msg_not_running "NFS"
135 if [ ! -f /var/lock/subsys/nfs ]; then
139 /sbin/pidof rpc.mountd >/dev/null 2>&1; MOUNTD="$?"
140 /sbin/pidof nfsd >/dev/null 2>&1; NFSD="$?"
141 if [ $MOUNTD = 1 -o $NFSD = 1 ]; then
145 if [ /etc/exports -nt /var/lock/subsys/nfs ]; then
155 [ $RETVAL -eq 0 ] && RETVAL=$RET
158 msg_usage "$0 {start|stop|restart|reload|force-reload|probe|status}"