]>
Commit | Line | Data |
---|---|---|
042f4ecc JR |
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 | ||
042f4ecc JR |
37 | start() { |
38 | # Check if the service is already running? | |
39 | if [ -f /var/lock/subsys/nfslock ]; then | |
40 | msg_already_running "RPC statd" | |
41 | return | |
42 | fi | |
43 | ||
44 | # Set the ports lockd should listen on | |
45 | if [ -n "$LOCKD_TCPPORT" ]; then | |
46 | /sbin/sysctl -w fs.nfs.nlm_tcpport=$LOCKD_TCPPORT >/dev/null 2>&1 | |
47 | fi | |
48 | if [ -n "$LOCKD_UDPPORT" ]; then | |
49 | /sbin/sysctl -w fs.nfs.nlm_udpport=$LOCKD_UDPPORT >/dev/null 2>&1 | |
50 | fi | |
51 | ||
042f4ecc JR |
52 | # Start daemons. |
53 | # Don't put sm-notify here, statd will run it when started | |
54 | msg_starting "RPC statd" | |
678e9da9 | 55 | daemon /sbin/rpc.statd $STATDOPTIONS |
042f4ecc JR |
56 | RETVAL=$? |
57 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nfslock | |
58 | } | |
59 | ||
60 | stop() { | |
61 | if [ ! -f /var/lock/subsys/nfslock ]; then | |
62 | msg_not_running "RPC statd" | |
63 | return | |
64 | fi | |
65 | ||
66 | # Reset the lockd ports if they were set | |
67 | if [ -n "$LOCKD_TCPPORT" ]; then | |
68 | /sbin/sysctl -w fs.nfs.nlm_tcpport=0 >/dev/null 2>&1 | |
69 | fi | |
70 | if [ -n "$LOCKD_UDPPORT" ]; then | |
71 | /sbin/sysctl -w fs.nfs.nlm_udpport=0 >/dev/null 2>&1 | |
72 | fi | |
73 | # Stop daemons. | |
74 | msg_stopping "RPC statd" | |
75 | killproc rpc.statd | |
76 | rm -f /var/lock/subsys/nfslock | |
77 | } | |
78 | ||
79 | RETVAL=0 | |
80 | # See how we were called. | |
81 | case "$1" in | |
82 | start) | |
83 | start | |
84 | ;; | |
85 | stop) | |
86 | stop | |
87 | ;; | |
88 | restart|force-reload) | |
89 | stop | |
90 | start | |
91 | ;; | |
92 | probe) | |
93 | if [ ! -f /var/lock/subsys/nfslock ]; then | |
94 | echo start | |
95 | exit 0 | |
96 | fi | |
97 | /sbin/pidof rpc.statd >/dev/null 2>&1; STATD="$?" | |
98 | if [ $STATD = 1 ]; then | |
99 | echo restart | |
100 | exit 0 | |
101 | fi | |
102 | ;; | |
103 | status) | |
104 | status rpc.statd | |
105 | exit $? | |
106 | ;; | |
107 | *) | |
108 | msg_usage "$0 {start|stop|restart|force-reload|probe|status}" | |
109 | exit 3 | |
110 | esac | |
111 | ||
112 | exit $RETVAL |