]> git.pld-linux.org Git - packages/nfs-utils.git/blob - nfs.init
- lock/subsus files for svcgssd
[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 "NFS daemon"
25                 exit 1
26         fi
27 else
28         exit 0
29 fi
30
31 start() {
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"
37                                 exit 0
38                         fi
39                 fi
40
41                 if ! is_yes "$NFS4" ; then
42                         RPCMOUNTOPTIONS="$RPCMOUNTOPTIONS --no-nfs-version 4"
43                 fi
44
45                 # Start daemons.
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
51                 fi
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
64                         fi
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
69                         fi
70                     fi
71                 fi
72                 msg_starting "NFS daemon"
73                 daemon rpc.nfsd $RPCNFSDCOUNT
74                 touch /var/lock/subsys/nfs
75         else
76                 msg_already_running "NFS daemon"
77         fi
78 }
79
80 stop() {
81         if [ -f /var/lock/subsys/nfs ]; then
82                 # Stop daemons.
83                 msg_stopping "NFS mountd"
84                 killproc rpc.mountd
85                 msg_stopping "NFS daemon"
86                 killproc nfsd -QUIT
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"
91                                 killproc rpc.svcgssd
92                                 rm -f /var/lock/subsys/svcgssd
93                             fi
94                             if [ -f /var/lock/subsys/idmapd -a ! -f /var/lock/subsys/nfsfs ]; then
95                                 msg_stopping "NFS idmapd"
96                                 killproc rpc.idmapd
97                                 rm -f /var/lock/subsys/idmapd
98                             fi
99                         fi
100                 fi
101                 msg_stopping "NFS"
102                 daemon /usr/sbin/exportfs -au
103                 rm -f /var/lock/subsys/nfs
104         else
105                 msg_not_running "NFS"
106         fi
107 }
108
109 RETVAL=0
110 # See how we were called.
111 case "$1" in
112   start)
113         start
114         ;;
115   stop)
116         stop
117         ;;
118   restart)
119         stop
120         start
121         ;;
122   reload|force-reload)
123         if [ -f /var/lock/subsys/nfs ]; then
124                 msg_reloading "NFS"
125                 busy
126                 /usr/sbin/exportfs
127                 [ $? -ne 0 ] && RETVAL=7
128                 [ $RETVAL -eq 0 ] && ok || died
129         else
130                 msg_not_running "NFS"
131                 exit 7
132         fi
133         ;;
134   probe)
135         if [ ! -f /var/lock/subsys/nfs ]; then
136                 echo start
137                 exit 0
138         fi
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
142                 echo restart
143                 exit 0
144         fi
145         if [ /etc/exports -nt /var/lock/subsys/nfs ]; then
146                 echo reload
147                 exit 0
148         fi
149         ;;
150   status)
151         status rpc.mountd
152         RETVAL=$?
153         status nfsd
154         RET=$?
155         [ $RETVAL -eq 0 ] && RETVAL=$RET
156         ;;
157   *)
158         msg_usage "$0 {start|stop|restart|reload|force-reload|probe|status}"
159         exit 3
160 esac
161
162 exit $RETVAL
This page took 0.050689 seconds and 4 git commands to generate.