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
31 if [ -x /sbin/pidof ] && [ "$1" != "stop" ]; then
32 [ -z "`/sbin/pidof portmap`" ] && nls "Error: portmap isn't running" && exit 0
36 [ -x /usr/sbin/rpc.nfsd ] || exit 0
37 [ -x /usr/sbin/rpc.mountd ] || exit 0
38 [ -f /etc/exports ] || exit 0
40 if ! is_yes "$NFS4" ; then
41 RPCMOUNTOPTIONS="$RPCMOUNTOPTIONS --no-nfs-version 4"
45 # See how we were called.
48 # Check if the service is already running?
49 if [ ! -f /var/lock/subsys/nfs ]; then
51 modprobe -s nfsd > /dev/null 2>&1
52 if [ "$(kernelverser)" -ge "002006" ]; then
53 grep -q nfsd /proc/filesystems && \
54 ! grep -q nfsd /proc/mounts && \
55 run_cmd "Mounting /proc/fs/nfsd filesystem" mount -t nfsd nfsd /proc/fs/nfsd
57 msg_starting "NFS exportfs"
58 daemon /usr/sbin/exportfs -r
59 msg_starting "NFS mountd"
60 daemon rpc.mountd $RPCMOUNTOPTIONS
61 if is_yes "$NFS4" ; then
62 if (grep -q rpc_pipefs /proc/filesystems); then
63 ! grep -q rpc_pipefs /proc/mounts && \
64 run_cmd "Mounting /var/lib/nfs/rpc_pipefs filesystem" mount -t rpc_pipefs rpc_pipefs /var/lib/nfs/rpc_pipefs
65 if [ ! -f /var/lock/subsys/idmapd ]; then
66 msg_starting "NFS idmapd"
67 daemon rpc.idmapd $RPCIDMAPOPTIONS
68 [ $? = 0 ] && touch /var/lock/subsys/idmapd
70 msg_starting "NFS svcgssd"
71 daemon rpc.svcgssd $RPCSVCGSSOPTIONS
74 msg_starting "NFS daemon"
75 daemon rpc.nfsd $RPCNFSDCOUNT
76 touch /var/lock/subsys/nfs
78 msg_already_running "NFS"
82 if [ -f /var/lock/subsys/nfs ]; then
84 msg_stopping "NFS mountd"
86 msg_stopping "NFS daemon"
88 if is_yes "$NFS4" ; then
89 if (grep -q rpc_pipefs /proc/filesystems); then
90 msg_stopping "NFS svcgssd"
92 if [ -f /var/lock/subsys/idmapd -a ! -f /var/lock/subsys/nfsfs ]; then
93 msg_stopping "NFS idmapd"
95 rm -f /var/lock/subsys/idmapd
100 daemon /usr/sbin/exportfs -au
101 rm -f /var/lock/subsys/nfs
103 msg_not_running "NFS"
111 [ $RETVAL -eq 0 ] && RETVAL=$RET
123 if [ -f /var/lock/subsys/nfs ]; then
127 [ $? -ne 0 ] && RETVAL=7
128 [ $RETVAL -eq 0 ] && ok || died
130 msg_not_running "NFS" >&2
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
151 msg_usage "$0 {start|stop|restart|reload|force-reload|probe|status}"