]> git.pld-linux.org Git - packages/nfs-utils.git/blob - nfs.init
- unified versions for nfs-server, knfsd and nfs-utils
[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 [ "${NETWORKING}" = "no" ]; then
23         echo "WARNING: Networking is down. Knfsd can't be run"
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         # Start daemons.
40         if [ NFSDTYPE = "U" ] ; then
41                 show "Starting NFS mountd"
42                 daemon rpc.mountd
43                 show "Starting NFS daemon"
44                 daemon rpc.nfsd
45         else
46                 show "Starting NFS services"
47                 daemon /usr/sbin/exportfs -r
48                 show "Starting NFS mountd"
49                 daemon rpc.mountd $RPCMOUNTDOPTS
50                 show "Starting NFS daemon"
51                 daemon rpc.nfsd $RPCNFSDCOUNT
52         fi
53         touch /var/lock/subsys/nfs
54         ;;
55   stop)
56         # Stop daemons.
57         if [ NFSDTYPE = "U" ] ; then
58                 show "Shutting down NFS mountd"
59                 killproc rpc.mountd
60                 show "Shutting down NFS daemon"
61                 killproc rpc.nfsd
62         else
63                 show "Shutting down NFS services"
64                 daemon /usr/sbin/exportfs -au
65                 show "Shutting down NFS mountd"
66                 killproc rpc.mountd
67                 show "Shutting down NFS daemon"
68                 killproc nfsd -QUIT
69         fi
70         rm -f /var/lock/subsys/nfs
71         ;;
72   status)
73         status rpc.mountd
74         if [ NFSDTYPE = "U" ] ; then
75                 status rpc.nfsd
76         else
77                 status nfsd
78         fi
79         ;;
80   restart)
81         if [ NFSDTYPE = "U" ] ; then
82                 $0 stop
83                 $0 start
84         else
85                 show "Restarting NFS services (killing)"
86                 killproc rpc.mountd
87                 show "Restarting NFS services (starting)"
88                 daemon rpc.mountd $RPCMOUNTDOPTS
89                 /usr/sbin/exportfs -r
90                 touch /var/lock/subsys/nfs
91         fi
92         ;;
93   reload)
94         [ NFSDTYPE = "U" ] && exit 0
95         /usr/sbin/exportfs
96         touch /var/lock/subsys/nfs
97         ;;
98   probe)
99         [ NFSDTYPE = "U" ] && exit 0
100         if [ ! -f /var/lock/subsys/nfs ] ; then
101           echo start; exit 0
102         fi
103         /sbin/pidof rpc.mountd >/dev/null 2>&1; MOUNTD="$?"
104         /sbin/pidof nfsd >/dev/null 2>&1; NFSD="$?"
105         if [ $MOUNTD = 1 -o $NFSD = 1 ] ; then
106           echo restart; exit 0
107         fi
108         if [ /etc/exports -nt /var/lock/subsys/nfs ] ; then
109           echo reload; exit 0
110         fi
111         ;;
112   *)
113         echo "Usage: nfs {start|stop|status|restart|reload}"
114         exit 1
115 esac
116
117 exit 0
This page took 0.285589 seconds and 4 git commands to generate.