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