]>
Commit | Line | Data |
---|---|---|
d419f9f1 JR |
1 | #!/bin/sh |
2 | # | |
ff100ffc | 3 | # nfslock This shell script takes care of starting and stopping |
3ddf9c2b | 4 | # the NSM status monitor - rpc.statd |
d419f9f1 | 5 | # |
891a86c9 | 6 | # chkconfig: 345 14 82 |
3ddf9c2b JR |
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. | |
f6619580 | 12 | # probe: true |
d419f9f1 JR |
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. | |
ff100ffc | 24 | if is_yes "${NETWORKING}"; then |
b69cfb4d | 25 | if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then |
3ddf9c2b | 26 | msg_network_down "RPC statd" |
ff100ffc | 27 | exit 1 |
28 | fi | |
29 | else | |
30 | exit 0 | |
d419f9f1 JR |
31 | fi |
32 | ||
fcdc7f4e JR |
33 | if [ "$1" != "stop" ]; then |
34 | check_portmapper || { nls "Error: portmap isn't running" && exit 0; } | |
d419f9f1 JR |
35 | fi |
36 | ||
fb01afbb JR |
37 | # /usr may be on NFS, fail silently, nfsfs will start it |
38 | [ -x /usr/sbin/rpc.statd ] || exit 0 | |
39 | ||
ad615b8a | 40 | start() { |
73f8a2e1 JB |
41 | # Check if the service is already running? |
42 | if [ ! -f /var/lock/subsys/nfslock ]; then | |
fb01afbb JR |
43 | # Set the ports lockd should listen on |
44 | if [ -n "$LOCKD_TCPPORT" ]; then | |
45 | /sbin/sysctl -w fs.nfs.nlm_tcpport=$LOCKD_TCPPORT >/dev/null 2>&1 | |
46 | fi | |
47 | if [ -n "$LOCKD_UDPPORT" ]; then | |
48 | /sbin/sysctl -w fs.nfs.nlm_udpport=$LOCKD_UDPPORT >/dev/null 2>&1 | |
49 | fi | |
50 | ||
51 | [ -n "$STATD_PORT" ] && STATDOPTS="$STATDOPTS -p $STATD_PORT" | |
52 | [ -n "$STATD_OUTPORT" ] && STATDOPTS="$STATDOPTS -o $STATD_OUTPORT" | |
53 | ||
73f8a2e1 | 54 | # Start daemons. |
644f8a35 | 55 | # Don't put sm-notify here, statd will run it when started |
3ddf9c2b | 56 | msg_starting "RPC statd" |
cade9e7d JR |
57 | daemon rpc.statd $STATDOPTS |
58 | RETVAL=$? | |
59 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nfslock | |
73f8a2e1 | 60 | else |
3ddf9c2b | 61 | msg_already_running "RPC statd" |
73f8a2e1 | 62 | fi |
ad615b8a ER |
63 | } |
64 | ||
65 | stop() { | |
ff100ffc | 66 | if [ -f /var/lock/subsys/nfslock ]; then |
fb01afbb JR |
67 | # Reset the lockd ports if they were set |
68 | if [ -n "$LOCKD_TCPPORT" ]; then | |
69 | /sbin/sysctl -w fs.nfs.nlm_tcpport=0 >/dev/null 2>&1 | |
70 | fi | |
71 | if [ -n "$LOCKD_UDPPORT" ]; then | |
72 | /sbin/sysctl -w fs.nfs.nlm_udpport=0 >/dev/null 2>&1 | |
73 | fi | |
73f8a2e1 | 74 | # Stop daemons. |
3ddf9c2b | 75 | msg_stopping "RPC statd" |
cade9e7d | 76 | killproc rpc.statd |
73f8a2e1 JB |
77 | rm -f /var/lock/subsys/nfslock |
78 | else | |
3ddf9c2b | 79 | msg_not_running "RPC statd" |
73f8a2e1 | 80 | fi |
ad615b8a ER |
81 | } |
82 | ||
83 | RETVAL=0 | |
84 | # See how we were called. | |
85 | case "$1" in | |
86 | start) | |
87 | start | |
88 | ;; | |
89 | stop) | |
90 | stop | |
d419f9f1 JR |
91 | ;; |
92 | status) | |
cade9e7d JR |
93 | status rpc.statd |
94 | exit $? | |
d419f9f1 | 95 | ;; |
5246d326 | 96 | restart|force-reload) |
ad615b8a ER |
97 | stop |
98 | start | |
d419f9f1 JR |
99 | ;; |
100 | probe) | |
5da51246 | 101 | if [ ! -f /var/lock/subsys/nfslock ]; then |
ff100ffc | 102 | echo start |
103 | exit 0 | |
d419f9f1 | 104 | fi |
cade9e7d JR |
105 | /sbin/pidof rpc.statd >/dev/null 2>&1; STATD="$?" |
106 | if [ $STATD = 1 ]; then | |
107 | echo restart | |
ff100ffc | 108 | exit 0 |
d419f9f1 JR |
109 | fi |
110 | ;; | |
111 | *) | |
5246d326 | 112 | msg_usage "$0 {start|stop|restart|force-reload|probe|status}" |
113 | exit 3 | |
d419f9f1 JR |
114 | esac |
115 | ||
5246d326 | 116 | exit $RETVAL |