#!/bin/sh
#
-# nfslock This shell script takes care of starting and stopping
-# the NFS file locking service.
+# nfslock This shell script takes care of starting and stopping
+# the NSM status monitor - rpc.statd
#
-# chkconfig: 345 61 19
-# description: NFS is a popular protocol for file sharing across \
-# TCP/IP networks. This service provides NFS file \
-# locking functionality.
-# probe: true
+# chkconfig: 345 14 82
+# description: The rpc.statd server implements the NSM \
+# (Network Status Monitor) RPC protocol. \
+# It is used by the NFS file locking service, lockd \
+# to implement lock recovery when the NFS server \
+# machine crashes and reboots.
+# probe: true
# Source function library.
. /etc/rc.d/init.d/functions
[ -f /etc/sysconfig/nfslock ] && . /etc/sysconfig/nfslock
# Check that networking is up.
-if is_no "${NETWORKING}"; then
- msg_Network_Down "NFS lockd"
- exit 1
+if is_yes "${NETWORKING}"; then
+ if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
+ msg_network_down "RPC statd"
+ exit 1
+ fi
+else
+ exit 0
fi
-if [ -x /sbin/pidof ] && [ "$1" != "stop" ]; then
- [ -z "`/sbin/pidof portmap`" ] && echo "Error: portmap isn't running" && exit 0
+if [ "$1" != "stop" ]; then
+ check_portmapper || { nls "Error: portmap isn't running" && exit 0; }
fi
-# Sanity checks
-[ -x /usr/sbin/rpc.lockd ] || exit 0
-[ -x /usr/sbin/rpc.statd ] || exit 0
+start() {
+ # Check if the service is already running?
+ if [ -f /var/lock/subsys/nfslock ]; then
+ msg_already_running "RPC statd"
+ return
+ fi
+
+ # Set the ports lockd should listen on
+ if [ -n "$LOCKD_TCPPORT" ]; then
+ /sbin/sysctl -w fs.nfs.nlm_tcpport=$LOCKD_TCPPORT >/dev/null 2>&1
+ fi
+ if [ -n "$LOCKD_UDPPORT" ]; then
+ /sbin/sysctl -w fs.nfs.nlm_udpport=$LOCKD_UDPPORT >/dev/null 2>&1
+ fi
-# See how we were called.
-case "$1" in
- start)
# Start daemons.
- msg_starting "NFS lockd"
- daemon rpc.lockd
- msg_starting "NFS statd"
- daemon rpc.statd
- touch /var/lock/subsys/nfslock
- ;;
- stop)
+ # Don't put sm-notify here, statd will run it when started
+ msg_starting "RPC statd"
+ daemon /sbin/rpc.statd $STATDOPTIONS
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nfslock
+}
+
+stop() {
+ if [ ! -f /var/lock/subsys/nfslock ]; then
+ msg_not_running "RPC statd"
+ return
+ fi
+
+ # Reset the lockd ports if they were set
+ if [ -n "$LOCKD_TCPPORT" ]; then
+ /sbin/sysctl -w fs.nfs.nlm_tcpport=0 >/dev/null 2>&1
+ fi
+ if [ -n "$LOCKD_UDPPORT" ]; then
+ /sbin/sysctl -w fs.nfs.nlm_udpport=0 >/dev/null 2>&1
+ fi
# Stop daemons.
- msg_stopping "NFS lockd"
- killproc lockd
- msg_stopping "NFS statd"
+ msg_stopping "RPC statd"
killproc rpc.statd
rm -f /var/lock/subsys/nfslock
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+ start)
+ start
;;
- status)
- status lockd
- status rpc.statd
+ stop)
+ stop
;;
- restart)
- $0 stop
- $0 start
+ restart|force-reload)
+ stop
+ start
;;
probe)
- if [ ! -f /var/lock/subsys/nfslock ] ; then
- echo start; exit 0
+ if [ ! -f /var/lock/subsys/nfslock ]; then
+ echo start
+ exit 0
fi
/sbin/pidof rpc.statd >/dev/null 2>&1; STATD="$?"
- /sbin/pidof lockd >/dev/null 2>&1; LOCKD="$?"
- if [ $STATD = 1 -o $LOCKD = 1 ] ; then
- echo restart; exit 0
+ if [ $STATD = 1 ]; then
+ echo restart
+ exit 0
fi
;;
+ status)
+ status rpc.statd
+ exit $?
+ ;;
*)
- msg_Usage "$0 {start|stop|status|restart}"
- exit 1
+ msg_usage "$0 {start|stop|restart|force-reload|probe|status}"
+ exit 3
esac
-exit 0
+exit $RETVAL