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
41 # See how we were called.
44 # Check if the service is already running?
45 if [ ! -f /var/lock/subsys/nfs ]; then
47 if [ "$NFSDTYPE" = "U" ]; then
48 msg_starting "NFS mountd"
49 daemon rpc.mountd $RPCMOUNTOPTIONS
50 msg_starting "NFS daemon"
51 daemon rpc.nfsd $RPCNFSDCOUNT
53 modprobe -s nfsd > /dev/null 2>&1
54 if [ "$(kernelverser)" -ge "002006" ] && \
55 grep -q nfsd /proc/filesystems && \
56 ! grep -q nfsd /proc/mounts; then
57 run_cmd "Mounting /proc/fs/nfsd filesystem" mount -t nfsd nfsd /proc/fs/nfsd
58 grep -q rpc_pipefs /proc/filesystems && \
59 ! grep -q rpc_pipefs /proc/mounts; then
60 run_cmd "Mounting /var/lib/nfs/rpc_pipefs filesystem" mount -t rpc_pipefs rpc_pipefs /var/lib/nfs/rpc_pipefs
63 daemon /usr/sbin/exportfs -r
64 msg_starting "NFS mountd"
65 daemon rpc.mountd $RPCMOUNTOPTIONS
66 if (grep -q nfs4 /proc/filesystems); then
67 if [ ! -f /var/lock/subsys/idmapd ]; then
68 msg_starting "NFS idmapd"
69 daemon rpc.idmapd $RPCIDMAPOPTIONS
70 [ $? = 0 ] && touch /var/lock/subsys/idmapd
72 msg_starting "NFS svcgssd"
73 daemon rpc.svcgssd $RPCSVCGSSOPTIONS
75 msg_starting "NFS daemon"
76 daemon rpc.nfsd $RPCNFSDCOUNT
78 touch /var/lock/subsys/nfs
80 msg_already_running "NFS"
84 if [ -f /var/lock/subsys/nfs ]; then
86 if [ "$NFSDTYPE" = "U" ]; then
87 msg_stopping "NFS mountd"
89 msg_stopping "NFS daemon"
92 msg_stopping "NFS mountd"
94 msg_stopping "NFS daemon"
96 if (grep -q nfs4 /proc/filesystems); then
97 msg_stopping "NFS svcgssd"
99 if [ -f /var/lock/subsys/idmapd -a ! -f /var/lock/subsys/nfsfs ]; then
100 msg_stopping "NFS idmapd"
105 daemon /usr/sbin/exportfs -au
107 rm -f /var/lock/subsys/nfs
109 msg_not_running "NFS"
115 if [ "$NFSDTYPE" = "U" ]; then
121 [ $RETVAL -eq 0 ] && RETVAL=$RET
129 if [ "$NFSDTYPE" = "U" ]; then
137 [ "$NFSDTYPE" = "U" ] && exit 0
138 if [ -f /var/lock/subsys/nfs ]; then
142 [ $? -ne 0 ] && RETVAL=7
143 [ $RETVAL -eq 0 ] && ok || died
145 msg_not_running "NFS" >&2
150 [ "$NFSDTYPE" = "U" ] && exit 0
151 if [ ! -f /var/lock/subsys/nfs ]; then
155 /sbin/pidof rpc.mountd >/dev/null 2>&1; MOUNTD="$?"
156 /sbin/pidof nfsd >/dev/null 2>&1; NFSD="$?"
157 if [ $MOUNTD = 1 -o $NFSD = 1 ]; then
161 if [ /etc/exports -nt /var/lock/subsys/nfs ]; then
167 msg_usage "$0 {start|stop|restart|reload|force-reload|probe|status}"