]> git.pld-linux.org Git - packages/nfs-utils.git/blob - nfs.init
- RPCMOUNTOPTIONS moved to start
[packages/nfs-utils.git] / nfs.init
1 #!/bin/sh
2 #
3 # nfs           This shell script takes care of starting and stopping
4 #               the NFS services.
5 #
6 # chkconfig:    345 60 20
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.
10 # probe:        true
11
12 # Source function library
13 . /etc/rc.d/init.d/functions
14
15 # Get network config
16 . /etc/sysconfig/network
17
18 # Get service config
19 [ -f /etc/sysconfig/nfsd ] && . /etc/sysconfig/nfsd
20
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 NFSD
25                 exit 1
26         fi
27 else
28         exit 0
29 fi
30
31 # Sanity checks
32 [ -x /usr/sbin/rpc.nfsd ] || exit 0
33 [ -x /usr/sbin/rpc.mountd ] || exit 0
34 [ -f /etc/exports ] || exit 0
35
36 start() {
37         # Check if the service is already running?
38         if [ ! -f /var/lock/subsys/nfs ]; then
39                 if [ -x /sbin/pidof ]; then
40                         if [ -z "`/sbin/pidof portmap`" ]; then
41                                 nls "Error: portmap isn't running"
42                                 exit 0
43                         fi
44                 fi
45
46                 if ! is_yes "$NFS4" ; then
47                         RPCMOUNTOPTIONS="$RPCMOUNTOPTIONS --no-nfs-version 4"
48                 fi
49
50                 # Start daemons.
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
56                 fi
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
69                         fi
70                         msg_starting "NFS svcgssd"
71                         daemon rpc.svcgssd $RPCSVCGSSOPTIONS
72                     fi
73                 fi
74                 msg_starting "NFS daemon"
75                 daemon rpc.nfsd $RPCNFSDCOUNT
76                 touch /var/lock/subsys/nfs
77         else
78                 msg_already_running "NFS"
79         fi
80 }
81
82 stop() {
83         if [ -f /var/lock/subsys/nfs ]; then
84                 # Stop daemons.
85                 msg_stopping "NFS mountd"
86                 killproc rpc.mountd
87                 msg_stopping "NFS daemon"
88                 killproc nfsd -QUIT
89                 if is_yes "$NFS4" ; then
90                         if (grep -q rpc_pipefs /proc/filesystems); then
91                             msg_stopping "NFS svcgssd"
92                             killproc rpc.svcgssd
93                             if [ -f /var/lock/subsys/idmapd -a ! -f /var/lock/subsys/nfsfs ]; then
94                                 msg_stopping "NFS idmapd"
95                                 killproc rpc.idmapd
96                                 rm -f /var/lock/subsys/idmapd
97                             fi
98                         fi
99                 fi
100                 msg_stopping "NFS"
101                 daemon /usr/sbin/exportfs -au
102                 rm -f /var/lock/subsys/nfs
103         else
104                 msg_not_running "NFS"
105         fi
106 }
107
108 RETVAL=0
109 # See how we were called.
110 case "$1" in
111   start)
112         start
113         ;;
114   stop)
115         stop
116         ;;
117   status)
118         status rpc.mountd
119         RETVAL=$?
120         status nfsd
121         RET=$?
122         [ $RETVAL -eq 0 ] && RETVAL=$RET
123         ;;
124   restart)
125         stop
126         start
127         ;;
128   reload|force-reload)
129         if [ -f /var/lock/subsys/nfs ]; then
130                 msg_reloading "NFS"
131                 busy
132                 /usr/sbin/exportfs
133                 [ $? -ne 0 ] && RETVAL=7
134                 [ $RETVAL -eq 0 ] && ok || died
135         else
136                 msg_not_running "NFS"
137                 exit 7
138         fi
139         ;;
140   probe)
141         if [ ! -f /var/lock/subsys/nfs ]; then
142                 echo start
143                 exit 0
144         fi
145         /sbin/pidof rpc.mountd >/dev/null 2>&1; MOUNTD="$?"
146         /sbin/pidof nfsd >/dev/null 2>&1; NFSD="$?"
147         if [ $MOUNTD = 1 -o $NFSD = 1 ]; then
148                 echo restart
149                 exit 0
150         fi
151         if [ /etc/exports -nt /var/lock/subsys/nfs ]; then
152                 echo reload
153                 exit 0
154         fi
155         ;;
156   *)
157         msg_usage "$0 {start|stop|restart|reload|force-reload|probe|status}"
158         exit 3
159 esac
160
161 exit $RETVAL
This page took 0.107952 seconds and 4 git commands to generate.