]> git.pld-linux.org Git - packages/nfs-utils.git/blob - nfslock.init
- updated to 1.2.3
[packages/nfs-utils.git] / nfslock.init
1 #!/bin/sh
2 #
3 # nfslock       This shell script takes care of starting and stopping
4 #               the NSM status monitor - rpc.statd
5 #
6 # chkconfig:    345 14 82
7 # description:  The rpc.statd server implements the NSM \
8 #               (Network  Status  Monitor) RPC protocol. \
9 #               It is used by the NFS file locking service, lockd \
10 #               to implement lock recovery when the NFS server \
11 #               machine crashes and reboots.
12 # probe:        true
13
14 # Source function library.
15 . /etc/rc.d/init.d/functions
16
17 # Get network config
18 . /etc/sysconfig/network
19
20 # Get service config
21 [ -f /etc/sysconfig/nfslock ] && . /etc/sysconfig/nfslock
22
23 # Check that networking is up.
24 if is_yes "${NETWORKING}"; then
25         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
26                 msg_network_down "RPC statd"
27                 exit 1
28         fi
29 else
30         exit 0
31 fi
32
33 if [ "$1" != "stop" ]; then
34         check_portmapper || { nls "Error: portmap isn't running" && exit 0; }
35 fi
36
37 # /usr may be on NFS, fail silently, nfsfs will start it
38 [ -x /usr/sbin/rpc.statd ] || exit 0
39
40 start() {
41         # Check if the service is already running?
42         if [ -f /var/lock/subsys/nfslock ]; then
43                 msg_already_running "RPC statd"
44                 return
45         fi
46
47         # Set the ports lockd should listen on
48         if [ -n "$LOCKD_TCPPORT" ]; then
49                 /sbin/sysctl -w fs.nfs.nlm_tcpport=$LOCKD_TCPPORT >/dev/null 2>&1
50         fi
51         if [ -n "$LOCKD_UDPPORT" ]; then
52                 /sbin/sysctl -w fs.nfs.nlm_udpport=$LOCKD_UDPPORT >/dev/null 2>&1
53         fi
54
55         [ -n "$STATD_PORT" ] && STATDOPTS="$STATDOPTS -p $STATD_PORT"
56         [ -n "$STATD_OUTPORT" ] && STATDOPTS="$STATDOPTS -o $STATD_OUTPORT"
57
58         # Start daemons.
59         # Don't put sm-notify here, statd will run it when started
60         msg_starting "RPC statd"
61         daemon /usr/sbin/rpc.statd $STATDOPTS
62         RETVAL=$?
63         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nfslock
64 }
65
66 stop() {
67         if [ ! -f /var/lock/subsys/nfslock ]; then
68                 msg_not_running "RPC statd"
69                 return
70         fi
71
72         # Reset the lockd ports if they were set
73         if [ -n "$LOCKD_TCPPORT" ]; then
74                 /sbin/sysctl -w fs.nfs.nlm_tcpport=0 >/dev/null 2>&1
75         fi
76         if [ -n "$LOCKD_UDPPORT" ]; then
77                 /sbin/sysctl -w fs.nfs.nlm_udpport=0 >/dev/null 2>&1
78         fi
79         # Stop daemons.
80         msg_stopping "RPC statd"
81         killproc rpc.statd
82         rm -f /var/lock/subsys/nfslock
83 }
84
85 RETVAL=0
86 # See how we were called.
87 case "$1" in
88   start)
89         start
90         ;;
91   stop)
92         stop
93         ;;
94   restart|force-reload)
95         stop
96         start
97         ;;
98   probe)
99         if [ ! -f /var/lock/subsys/nfslock ]; then
100                 echo start
101                 exit 0
102         fi
103         /sbin/pidof rpc.statd >/dev/null 2>&1; STATD="$?"
104         if [ $STATD = 1 ]; then
105                 echo restart
106                 exit 0
107         fi
108         ;;
109   status)
110         status rpc.statd
111         exit $?
112         ;;
113   *)
114         msg_usage "$0 {start|stop|restart|force-reload|probe|status}"
115         exit 3
116 esac
117
118 exit $RETVAL
This page took 0.059747 seconds and 3 git commands to generate.