cvsdist c905793
#!/bin/sh
cvsdist c905793
#
cvsdist c905793
# nfslock       This shell script takes care of starting and stopping
cvsdist c905793
#               the NFS file locking service.
cvsdist c905793
#
cvsdist c905793
# chkconfig: 345 14 86
cvsdist c905793
# description: NFS is a popular protocol for file sharing across \
cvsdist c905793
#	       TCP/IP networks. This service provides NFS file \
cvsdist c905793
#	       locking functionality.
cvsdist c905793
# probe: true
cvsdist c905793
cvsdist c905793
# Source function library.
cvsdist c905793
. /etc/rc.d/init.d/functions
cvsdist c905793
cvsdist c905793
# Source networking configuration.
cvsdist c905793
if [ ! -f /etc/sysconfig/network ]; then
cvsdist c905793
    exit 0
cvsdist c905793
fi
cvsdist c905793
cvsdist 9d8f355
# Check for and source configuration file
cvsdist 9d8f355
[ -f /etc/sysconfig/nfs ] && . /etc/sysconfig/nfs
cvsdist 9d8f355
cvsdist c905793
. /etc/sysconfig/network
cvsdist c905793
cvsdist c905793
# Check that networking is up.
cvsdist 8fe6bc0
[ "${NETWORKING}" = "no" ] && exit 0
cvsdist c905793
cvsdist 7a8b656
# Start lockd from userland only if kernel <= 2.2.18
cvsdist 7a8b656
OS_RELEASE=`uname --release`
cvsdist 7a8b656
OS_RELEASE_MAJOR=`echo "$OS_RELEASE" | sed 's/\(^[0-9]\)\..*/\1/'`
cvsdist 7a8b656
OS_RELEASE_MINOR=`echo "$OS_RELEASE" | sed 's/\(^[0-9]\)\.\([0-9]*\)\..*/\2/'`
cvsdist 7a8b656
OS_RELEASE_VERSION=`echo "$OS_RELEASE" | sed 's/\(^[0-9]\)\.\([0-9]*\)\.\([0-9]*\).*/\3/'`
cvsdist 71d63d6
cvsdist 7a8b656
if [ "$OS_RELEASE_MAJOR" -le 2 -a "$OS_RELEASE_MINOR" -le 2 -a "$OS_RELEASE_VERSION" -le 18 ] ; then
cvsdist 7a8b656
    USERLAND_LOCKD="yes"
cvsdist 7a8b656
else
cvsdist 7a8b656
    USERLAND_LOCKD=
cvsdist 7a8b656
fi
cvsdist 71d63d6
cvsdist 7a8b656
if [ "$USERLAND_LOCKD" ] ; then
cvsdist 7a8b656
    [ -x /sbin/rpc.lockd ] || exit 0
cvsdist 71d63d6
fi
cvsdist 7a8b656
cvsdist 7a8b656
[ -x /sbin/rpc.statd ] || exit 0 
cvsdist 7a8b656
cvsdist 7a8b656
RETVAL=0
cvsdist 9d8f355
if [ -n "${STATD_HOSTNAME}" ]; then
cvsdist 9d8f355
    STATDARG="-n ${STATD_HOSTNAME}"
cvsdist 9d8f355
else
cvsdist 9d8f355
    STATDARG=""
cvsdist 9d8f355
fi
cvsdist 9d8f355
cvsdist c905793
cvsdist 71d63d6
start() {
cvsdist 5816d0e
    if [ ! -f /var/lock/subsys/nfslock ]; then
cvsdist c905793
	# Start daemons.
cvsdist 7a8b656
	if [ "$USERLAND_LOCKD" ]; then
cvsdist 4f69ea4
	  echo -n $"Starting NFS locking: "
cvsdist 71d63d6
	  daemon rpc.lockd
cvsdist 71d63d6
	  echo
cvsdist 71d63d6
	fi  
cvsdist 4f69ea4
	echo -n $"Starting NFS statd: "
cvsdist 9d8f355
	# See if a statd's ports has been defined
cvsdist 9d8f355
	[ -n "$STATD_PORT" ] && STATDARG="$STATDARG -p $STATD_PORT"
cvsdist 9d8f355
	[ -n "$STATD_OUTGOING_PORT" ] \
cvsdist 9d8f355
		&& STATDARG="$STATDARG -o $STATD_OUTGOING_PORT"
cvsdist 9d8f355
	daemon rpc.statd "$STATDARG"
cvsdist 71d63d6
	RETVAL=$?
cvsdist c905793
	echo
cvsdist 71d63d6
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/nfslock
cvsdist 5816d0e
    fi
cvsdist 5816d0e
    return $RETVAL
cvsdist 71d63d6
}
cvsdist 71d63d6
cvsdist 71d63d6
stop() {
cvsdist c905793
	# Stop daemons.
bb3850c
	echo -n $"Stopping NFS locking: "
cvsdist 7a8b656
	if [ "$USERLAND_LOCKD" ]; then
cvsdist 71d63d6
	   killproc lockd
f17a429
	else
f17a429
	   killproc lockd -KILL
cvsdist 71d63d6
	fi
bb3850c
	echo
cvsdist 4f69ea4
	echo -n $"Stopping NFS statd: "
cvsdist c905793
	killproc rpc.statd
cvsdist 71d63d6
	RETVAL=0
cvsdist c905793
	echo
cvsdist 71d63d6
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/nfslock
cvsdist 71d63d6
	return $RETVAL
cvsdist 71d63d6
}
cvsdist 71d63d6
cvsdist 71d63d6
# See how we were called.
cvsdist 71d63d6
case "$1" in
cvsdist 71d63d6
  start)
cvsdist 71d63d6
        start
cvsdist 71d63d6
	;;
cvsdist 71d63d6
  stop)
cvsdist 71d63d6
  	stop
cvsdist c905793
	;;
cvsdist c905793
  status)
cvsdist 7a8b656
	if [ "$USERLAND_LOCKD" ]; then
cvsdist 71d63d6
	  status lockd
cvsdist 71d63d6
	fi 
cvsdist c905793
	status rpc.statd
cvsdist c905793
	;;
cvsdist c905793
  restart)
cvsdist 71d63d6
        stop
cvsdist 71d63d6
	start
cvsdist c905793
	;;
cvsdist c905793
  probe)
cvsdist c905793
	if [ ! -f /var/lock/subsys/nfslock ] ; then
cvsdist 9d8f355
	  echo $"start"; exit 0
cvsdist c905793
	fi
cvsdist c905793
	/sbin/pidof rpc.statd >/dev/null 2>&1; STATD="$?"
cvsdist 7a8b656
	if [ "$USERLAND_LOCKD" ]; then
cvsdist 71d63d6
	   /sbin/pidof lockd >/dev/null 2>&1; LOCKD="$?"
cvsdist 71d63d6
	else
cvsdist 71d63d6
	   LOCKD=0
cvsdist 71d63d6
	fi
cvsdist c905793
	if [ $STATD = 1 -o $LOCKD = 1 ] ; then
cvsdist 9d8f355
	  echo $"restart"; exit 0
cvsdist c905793
	fi
cvsdist c905793
	;;
cvsdist 9d8f355
  condrestart)
cvsdist 9d8f355
  	[ -f /var/lock/subsys/nfslock ] && {
cvsdist 9d8f355
		stop
cvsdist 9d8f355
		start
cvsdist 9d8f355
	}
cvsdist 9d8f355
	;;
cvsdist c905793
  *)
cvsdist 9d8f355
	echo $"Usage: $0 {start|stop|status|restart|probe|condrestart}"
cvsdist c905793
	exit 1
cvsdist c905793
esac
cvsdist c905793
cvsdist c905793
exit 0