nfs-utils/nfslock.init
Steve Dickson ea858b4aab - Added upstream 1.2.1-rc1 patch
- Fix to check in closeall()
- Make --enable-tirpc the default
- Set all verbose types in gssd daemons
- Retry exports if getfh() fails
2009-06-22 14:31:55 +00:00

148 lines
3.2 KiB
Bash
Executable File

#!/bin/sh
#
# nfslock This shell script takes care of starting and stopping
# the NFS file locking service.
#
# chkconfig: 345 14 86
# description: NFS is a popular protocol for file sharing across \
# networks. This service provides NFS file locking \
# functionality.
# probe: true
### BEGIN INIT INFO
# Provides: nfslock
# Required-Start: $network $syslog
# Required-Stop: $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start up the NFS file locking sevice
# Description: NFS is a popular protocol for file sharing across \
# networks. This service provides NFS file locking \
# functionality.
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
if [ ! -f /etc/sysconfig/network ]; then
exit 6
fi
# Check for and source configuration file
LOCKDARG=""
STATDARG=""
[ -f /etc/sysconfig/nfs ] && . /etc/sysconfig/nfs
[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
RETVAL=0
start() {
# Check that networking is up.
[ "${NETWORKING}" = "no" ] && exit 6
[ -x /sbin/rpc.statd ] || exit 5
# Make sure the rpc.statd is not already running.
if status rpc.statd > /dev/null ; then
exit 0
fi
rm -f /var/lock/subsys/nfslock
# Make sure locks are recovered
rm -f /var/run/sm-notify.pid
# Start daemons.
# See if the kernel lockd should start up
# listening on a particular port
#
if [ -n "$LOCKD_TCPPORT" -o -n "$LOCKD_UDPPORT" ]; then
[ -x /sbin/modprobe ] && /sbin/modprobe lockd $LOCKDARG
[ -n "$LOCKD_TCPPORT" ] && \
/sbin/sysctl -w fs.nfs.nlm_tcpport=$LOCKD_TCPPORT >/dev/null 2>&1
[ -n "$LOCKD_UDPPORT" ] && \
/sbin/sysctl -w fs.nfs.nlm_udpport=$LOCKD_UDPPORT >/dev/null 2>&1
fi
echo -n $"Starting NFS statd: "
# Set statd's local hostname if defined
[ -n "${STATD_HOSTNAME}" ] && STATDARG="$STATDARG -n ${STATD_HOSTNAME}"
# See if a statd's ports has been defined
[ -n "$STATD_PORT" ] && STATDARG="$STATDARG -p $STATD_PORT"
[ -n "$STATD_OUTGOING_PORT" ] \
&& STATDARG="$STATDARG -o $STATD_OUTGOING_PORT"
# See if we have an HA-callout program specified
[ -n "$STATD_HA_CALLOUT" ] \
&& STATDARG="$STATDARG -H $STATD_HA_CALLOUT"
daemon rpc.statd "$STATDARG"
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/nfslock
return $RETVAL
}
stop() {
# Stop daemons.
if [ -n "`pidofproc lockd`" ]; then
echo -n $"Stopping NFS locking: "
killproc lockd -KILL
echo
fi
echo -n $"Stopping NFS statd: "
killproc rpc.statd
RETVAL=$?
echo
rm -f /var/lock/subsys/nfslock
rm -f /var/run/sm-notify.pid
return $RETVAL
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status rpc.statd
RETVAL=$?
;;
restart)
stop
start
;;
probe)
if [ ! -f /var/lock/subsys/nfslock ] ; then
echo $"start"; exit 0
fi
/sbin/pidof rpc.statd >/dev/null 2>&1
if [ $? = 1 ] ; then
echo $"restart"; exit 0
fi
;;
condrestart)
[ -f /var/lock/subsys/nfslock ] && {
stop
start
RETVAL=$?
}
;;
condstop)
[ -f /var/lock/subsys/nfslock ] && {
stop
RETVAL=$?
}
;;
*)
echo $"Usage: $0 {start|stop|status|restart|probe|condrestart|condstop}"
RETVAL=3
;;
esac
exit $RETVAL