]> git.pld-linux.org Git - packages/nfs-utils.git/blob - nfs.init
- fix restart targer (now restarting server do not cause hanging clients).
[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_no "${NETWORKING}"; then
23         msg_Network_Down NFSD
24         exit 1
25 fi
26
27 if [ -x /sbin/pidof ] && [ "$1" != "stop" ]; then
28         [ -z "`/sbin/pidof portmap`" ] && echo "Error: portmap isn't running" && 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 # See how we were called.
37 case "$1" in
38   start)
39         # Check if the service is already running?
40         if [ ! -f /var/lock/subsys/nfs ]; then
41                 # Start daemons.
42                 if [ "$NFSDTYPE" = "U" ] ; then
43                         msg_starting "NFS mountd"
44                         daemon rpc.mountd
45                         msg_starting "NFS daemon"
46                         daemon rpc.nfsd
47                 else
48                         msg_starting "NFS"
49                         daemon /usr/sbin/exportfs -r
50                         msg_starting "NFS mountd"
51                         daemon rpc.mountd $RPCMOUNTDOPTS
52                         msg_starting "NFS daemon"
53                         daemon rpc.nfsd $RPCNFSDCOUNT
54                 fi
55                 touch /var/lock/subsys/nfs
56         else
57                 msg_Already_Running "NFS"
58                 exit 1
59         fi
60         ;;
61   stop)
62         if [ -f /var/lock/subsys/nfs ]; then
63                 # Stop daemons.
64                 if [ "$NFSDTYPE" = "U" ] ; then
65                         msg_stopping "NFS mountd"
66                         killproc rpc.mountd
67                         msg_stopping "NFS daemon"
68                         killproc rpc.nfsd
69                 else
70                         msg_stopping "NFS mountd"
71                         killproc rpc.mountd
72                         msg_stopping "NFS daemon"
73                         killproc nfsd -QUIT
74                         msg_stopping "NFS"
75                         daemon /usr/sbin/exportfs -au
76                 fi
77                 rm -f /var/lock/subsys/nfs
78         else
79                 msg_Not_Running "NFS"
80                 exit 1
81         fi
82         ;;
83   status)
84         status rpc.mountd
85         if [ "$NFSDTYPE" = "U" ] ; then
86                 status rpc.nfsd
87         else
88                 status nfsd
89         fi
90         ;;
91   restart)
92         $0 stop
93         $0 start
94         ;;
95   reload)
96         [ "$NFSDTYPE" = "U" ] && exit 0
97         /usr/sbin/exportfs
98         touch /var/lock/subsys/nfs
99         ;;
100   probe)
101         [ "$NFSDTYPE" = "U" ] && exit 0
102         if [ ! -f /var/lock/subsys/nfs ] ; then
103           echo start; exit 0
104         fi
105         /sbin/pidof rpc.mountd >/dev/null 2>&1; MOUNTD="$?"
106         /sbin/pidof nfsd >/dev/null 2>&1; NFSD="$?"
107         if [ $MOUNTD = 1 -o $NFSD = 1 ] ; then
108           echo restart; exit 0
109         fi
110         if [ /etc/exports -nt /var/lock/subsys/nfs ] ; then
111           echo reload; exit 0
112         fi
113         ;;
114   *)
115         msg_usage "$0 {start|stop|status|restart|reload|probe}"
116         exit 1
117 esac
118
119 exit 0
This page took 0.076111 seconds and 4 git commands to generate.