]> git.decadent.org.uk Git - nfs-utils.git/blob - etc/redhat/nfs.init
c1b98eab3634f96b47c340908d9a9ab61ef08418
[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 # Number of servers to be started up by default
31 RPCNFSDCOUNT=8
32 # Default to NFS version 3.
33 RPCMOUNTDOPTS=""
34
35 # See how we were called.
36 case "$1" in
37   start)
38         # Start daemons.
39         action "Starting NFS services: " /usr/sbin/exportfs -r
40         echo -n "Starting NFS quotas: "
41         daemon rpc.rquotad
42         echo
43         echo -n "Starting NFS daemon: "
44         daemon rpc.nfsd $RPCNFSDCOUNT
45         echo
46
47         # Let's see if we support NFS version 3.
48         /usr/sbin/rpcinfo -u localhost nfs 3 &>/dev/null
49         if [ $? -ne 0 ]; then
50                 RPCMOUNTDOPTS="--no-nfs-version 3"
51         fi
52
53         # Let's see if we support NFS over TCP.
54         /usr/sbin/rpcinfo -p localhost | grep nfs | grep tcp &>/dev/null
55         if [ $? -ne 0 ]; then
56                 RPCMOUNTDOPTS="$RPCMOUNTDOPTS --no-tcp"
57         fi
58
59         echo -n "Starting NFS mountd: "
60         daemon rpc.mountd $RPCMOUNTDOPTS
61         echo
62         touch /var/lock/subsys/nfs
63         ;;
64   stop)
65         # Stop daemons.
66         echo -n "Shutting down NFS mountd: "
67         killproc rpc.mountd
68         echo
69         echo -n "Shutting down NFS daemon: "
70         killproc nfsd
71         echo
72         echo -n "Shutting down NFS quotas: "
73         killproc rpc.rquotad
74         echo
75         # Do it the last so that clients can still access the server
76         # when the server is running.
77         action "Shutting down NFS services: " /usr/sbin/exportfs -au
78         rm -f /var/lock/subsys/nfs
79         ;;
80   status)
81         status rpc.mountd
82         status nfsd
83         status rpc.rquotad
84         ;;
85   restart)
86         $0 stop
87         $0 start
88         ;;
89   reload)
90         /usr/sbin/exportfs -r
91         touch /var/lock/subsys/nfs
92         ;;
93   probe)
94         if [ ! -f /var/lock/subsys/nfs ] ; then
95           echo start; exit 0
96         fi
97         /sbin/pidof rpc.mountd >/dev/null 2>&1; MOUNTD="$?"
98         /sbin/pidof nfsd >/dev/null 2>&1; NFSD="$?"
99         if [ $MOUNTD = 1 -o $NFSD = 1 ] ; then
100           echo restart; exit 0
101         fi
102         if [ /etc/exports -nt /var/lock/subsys/nfs ] ; then
103           echo reload; exit 0
104         fi
105         ;;
106   *)
107         echo "Usage: nfs {start|stop|status|restart|reload}"
108         exit 1
109 esac
110
111 exit 0