]> git.decadent.org.uk Git - nfs-utils.git/blob - etc/redhat/nfs.init
2001-06-27 H.J. Lu <hjl@lucon.org>
[nfs-utils.git] / etc / redhat / nfs.init
1 #!/bin/sh
2 #
3 # nfs           This shell script takes care of starting and stopping
4 #               the NFS services.
5 #
6 # chkconfig: - 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 # Source networking configuration.
16 if [ ! -f /etc/sysconfig/network ]; then
17     exit 0
18 fi
19
20 . /etc/sysconfig/network
21
22 # Check that networking is up.
23 [ ${NETWORKING} = "no" ] && exit 0
24
25 [ -x /usr/sbin/rpc.nfsd ] || exit 0
26 [ -x /usr/sbin/rpc.mountd ] || exit 0
27 [ -x /usr/sbin/exportfs ] || exit 0
28 [ -s /etc/exports ] || exit 0
29
30 RQUOTAD=`type -path rpc.rquotad`        # Remote quota server
31
32 # Number of servers to be started up by default
33 RPCNFSDCOUNT=8
34 # Default to NFS version 3.
35 RPCMOUNTDOPTS=""
36
37 # See how we were called.
38 case "$1" in
39   start)
40         # Start daemons.
41         action "Starting NFS services: " /usr/sbin/exportfs -r
42         if [ -n "$RQUOTAD" ]; then
43                 echo -n "Starting NFS quotas: "
44                 daemon rpc.rquotad
45                 echo
46         fi
47         echo -n "Starting NFS daemon: "
48         daemon rpc.nfsd $RPCNFSDCOUNT
49         echo
50
51         # Let's see if we support NFS version 3.
52         /usr/sbin/rpcinfo -u localhost nfs 3 &>/dev/null
53         if [ $? -ne 0 ]; then
54                 RPCMOUNTDOPTS="--no-nfs-version 3"
55         fi
56
57         echo -n "Starting NFS mountd: "
58         daemon rpc.mountd $RPCMOUNTDOPTS
59         echo
60         touch /var/lock/subsys/nfs
61         ;;
62   stop)
63         # Stop daemons.
64         echo -n "Shutting down NFS mountd: "
65         killproc rpc.mountd
66         echo
67         echo -n "Shutting down NFS daemon: "
68         killproc nfsd
69         echo
70         echo -n "Shutting down NFS quotas: "
71         killproc rpc.rquotad
72         echo
73         # Do it the last so that clients can still access the server
74         # when the server is running.
75         action "Shutting down NFS services: " /usr/sbin/exportfs -au
76         rm -f /var/lock/subsys/nfs
77         ;;
78   status)
79         status rpc.mountd
80         status nfsd
81         status rpc.rquotad
82         ;;
83   restart)
84         $0 stop
85         $0 start
86         ;;
87   reload)
88         /usr/sbin/exportfs -r
89         touch /var/lock/subsys/nfs
90         ;;
91   probe)
92         if [ ! -f /var/lock/subsys/nfs ] ; then
93           echo start; exit 0
94         fi
95         /sbin/pidof rpc.mountd >/dev/null 2>&1; MOUNTD="$?"
96         /sbin/pidof nfsd >/dev/null 2>&1; NFSD="$?"
97         if [ $MOUNTD = 1 -o $NFSD = 1 ] ; then
98           echo restart; exit 0
99         fi
100         if [ /etc/exports -nt /var/lock/subsys/nfs ] ; then
101           echo reload; exit 0
102         fi
103         ;;
104   *)
105         echo "Usage: nfs {start|stop|status|restart|reload}"
106         exit 1
107 esac
108
109 exit 0