3 # nfslock This shell script takes care of starting and stopping
4 # the NSM status monitor - rpc.statd
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.
14 # Source function library.
15 . /etc/rc.d/init.d/functions
18 . /etc/sysconfig/network
21 [ -f /etc/sysconfig/nfslock ] && . /etc/sysconfig/nfslock
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"
33 if [ -x /sbin/pidof ] && [ "$1" != "stop" ]; then
34 [ -z "`/sbin/pidof portmap`" ] && nls "Error: portmap isn't running" && exit 0
37 # /usr may be on NFS, fail silently, nfsfs will start it
38 [ -x /usr/sbin/rpc.statd ] || exit 0
41 # Check if the service is already running?
42 if [ ! -f /var/lock/subsys/nfslock ]; then
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
47 if [ -n "$LOCKD_UDPPORT" ]; then
48 /sbin/sysctl -w fs.nfs.nlm_udpport=$LOCKD_UDPPORT >/dev/null 2>&1
51 [ -n "$STATD_PORT" ] && STATDOPTS="$STATDOPTS -p $STATD_PORT"
52 [ -n "$STATD_OUTPORT" ] && STATDOPTS="$STATDOPTS -o $STATD_OUTPORT"
55 # Don't put sm-notify here, statd will run it when started
56 msg_starting "RPC statd"
57 daemon rpc.statd $STATDOPTS
59 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nfslock
61 msg_already_running "RPC statd"
66 if [ -f /var/lock/subsys/nfslock ]; then
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
71 if [ -n "$LOCKD_UDPPORT" ]; then
72 /sbin/sysctl -w fs.nfs.nlm_udpport=0 >/dev/null 2>&1
75 msg_stopping "RPC statd"
77 rm -f /var/lock/subsys/nfslock
79 msg_not_running "RPC statd"
84 # See how we were called.
101 if [ ! -f /var/lock/subsys/nfslock ]; then
105 /sbin/pidof rpc.statd >/dev/null 2>&1; STATD="$?"
106 if [ $STATD = 1 ]; then
112 msg_usage "$0 {start|stop|restart|force-reload|probe|status}"