]> git.pld-linux.org Git - packages/nfs-utils.git/blob - nfs.init
- msg_Usage -> msg_usage
[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         if [ "$NFSDTYPE" = "U" ] ; then
93                 $0 stop
94                 $0 start
95         else
96                 show "Restarting NFS services (killing)"
97                 killproc rpc.mountd
98                 show "Restarting NFS services (starting)"
99                 daemon rpc.mountd $RPCMOUNTDOPTS
100                 /usr/sbin/exportfs -r
101                 touch /var/lock/subsys/nfs
102         fi
103         ;;
104   reload)
105         [ "$NFSDTYPE" = "U" ] && exit 0
106         /usr/sbin/exportfs
107         touch /var/lock/subsys/nfs
108         ;;
109   probe)
110         [ "$NFSDTYPE" = "U" ] && exit 0
111         if [ ! -f /var/lock/subsys/nfs ] ; then
112           echo start; exit 0
113         fi
114         /sbin/pidof rpc.mountd >/dev/null 2>&1; MOUNTD="$?"
115         /sbin/pidof nfsd >/dev/null 2>&1; NFSD="$?"
116         if [ $MOUNTD = 1 -o $NFSD = 1 ] ; then
117           echo restart; exit 0
118         fi
119         if [ /etc/exports -nt /var/lock/subsys/nfs ] ; then
120           echo reload; exit 0
121         fi
122         ;;
123   *)
124         msg_usage "$0 {start|stop|status|restart|reload|probe}"
125         exit 1
126 esac
127
128 exit 0
This page took 0.074033 seconds and 4 git commands to generate.