2004-09-09 09:14:13 +00:00
|
|
|
#!/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 \
|
|
|
|
# TCP/IP networks. This service provides NFS file \
|
|
|
|
# locking functionality.
|
|
|
|
# probe: true
|
|
|
|
|
|
|
|
# Source function library.
|
|
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
|
|
|
|
# Source networking configuration.
|
|
|
|
if [ ! -f /etc/sysconfig/network ]; then
|
2007-07-30 10:10:07 +00:00
|
|
|
exit 6
|
2004-09-09 09:14:13 +00:00
|
|
|
fi
|
|
|
|
|
2004-09-09 09:21:05 +00:00
|
|
|
# Check for and source configuration file
|
2008-04-25 15:39:48 +00:00
|
|
|
LOCKDARG=""
|
|
|
|
STATDARG=""
|
2004-09-09 09:21:05 +00:00
|
|
|
[ -f /etc/sysconfig/nfs ] && . /etc/sysconfig/nfs
|
|
|
|
|
2004-09-09 09:14:13 +00:00
|
|
|
. /etc/sysconfig/network
|
|
|
|
|
|
|
|
# Check that networking is up.
|
2007-07-30 10:10:07 +00:00
|
|
|
[ "${NETWORKING}" = "no" ] && exit 6
|
2004-09-09 09:14:13 +00:00
|
|
|
|
2007-07-30 10:10:07 +00:00
|
|
|
[ -x /sbin/rpc.statd ] || exit 5
|
2004-09-09 09:16:23 +00:00
|
|
|
|
|
|
|
RETVAL=0
|
2004-09-09 09:14:13 +00:00
|
|
|
|
2004-09-09 09:14:35 +00:00
|
|
|
start() {
|
2004-09-09 09:19:31 +00:00
|
|
|
if [ ! -f /var/lock/subsys/nfslock ]; then
|
2008-03-03 16:22:08 +00:00
|
|
|
|
|
|
|
# Make sure locks are recovered
|
|
|
|
rm -f /var/run/sm-notify.pid
|
|
|
|
|
2004-09-09 09:14:13 +00:00
|
|
|
# Start daemons.
|
2006-06-30 14:17:52 +00:00
|
|
|
# See if the kernel lockd should start up
|
|
|
|
# listening on a particular port
|
|
|
|
#
|
2008-04-25 15:39:48 +00:00
|
|
|
[ -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
|
|
|
|
[ -n "$LOCKDARG" ] && modprobe lockd $LOCKDARG
|
|
|
|
|
2004-09-09 09:18:00 +00:00
|
|
|
echo -n $"Starting NFS statd: "
|
2008-04-25 15:39:48 +00:00
|
|
|
# Set statd's local hostname if defined
|
|
|
|
[ -n "${STATD_HOSTNAME}" ] && STATDARG="$STATDARG -n ${STATD_HOSTNAME}"
|
|
|
|
|
2004-09-09 09:21:05 +00:00
|
|
|
# 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"
|
2008-04-25 15:39:48 +00:00
|
|
|
|
2006-08-16 14:39:56 +00:00
|
|
|
# See if we have an HA-callout program specified
|
|
|
|
[ -n "$STATD_HA_CALLOUT" ] \
|
|
|
|
&& STATDARG="$STATDARG -H $STATD_HA_CALLOUT"
|
2004-09-09 09:21:05 +00:00
|
|
|
daemon rpc.statd "$STATDARG"
|
2004-09-09 09:14:35 +00:00
|
|
|
RETVAL=$?
|
2004-09-09 09:14:13 +00:00
|
|
|
echo
|
2004-09-09 09:14:35 +00:00
|
|
|
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/nfslock
|
2004-09-09 09:19:31 +00:00
|
|
|
fi
|
|
|
|
return $RETVAL
|
2004-09-09 09:14:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
2004-09-09 09:14:13 +00:00
|
|
|
# Stop daemons.
|
2005-09-08 14:27:06 +00:00
|
|
|
if [ -n "`pidofproc lockd`" ]; then
|
|
|
|
echo -n $"Stopping NFS locking: "
|
|
|
|
killproc lockd -KILL
|
|
|
|
echo
|
2004-09-09 09:14:35 +00:00
|
|
|
fi
|
2006-06-30 14:17:52 +00:00
|
|
|
|
2004-09-09 09:18:00 +00:00
|
|
|
echo -n $"Stopping NFS statd: "
|
2004-09-09 09:14:13 +00:00
|
|
|
killproc rpc.statd
|
2007-05-16 17:34:55 +00:00
|
|
|
RETVAL=$?
|
2004-09-09 09:14:13 +00:00
|
|
|
echo
|
2007-05-16 17:34:55 +00:00
|
|
|
rm -f /var/lock/subsys/nfslock
|
2008-01-05 14:27:40 +00:00
|
|
|
rm -f /var/run/sm-notify.pid
|
2004-09-09 09:14:35 +00:00
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
# See how we were called.
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop
|
2004-09-09 09:14:13 +00:00
|
|
|
;;
|
|
|
|
status)
|
|
|
|
status rpc.statd
|
2008-04-25 15:39:48 +00:00
|
|
|
RETVAL=$?
|
2004-09-09 09:14:13 +00:00
|
|
|
;;
|
|
|
|
restart)
|
2008-04-25 15:39:48 +00:00
|
|
|
stop
|
2004-09-09 09:14:35 +00:00
|
|
|
start
|
2004-09-09 09:14:13 +00:00
|
|
|
;;
|
|
|
|
probe)
|
|
|
|
if [ ! -f /var/lock/subsys/nfslock ] ; then
|
2004-09-09 09:21:05 +00:00
|
|
|
echo $"start"; exit 0
|
2004-09-09 09:14:13 +00:00
|
|
|
fi
|
2008-04-25 15:39:48 +00:00
|
|
|
/sbin/pidof rpc.statd >/dev/null 2>&1
|
|
|
|
if [ $? = 1 ] ; then
|
2004-09-09 09:21:05 +00:00
|
|
|
echo $"restart"; exit 0
|
2004-09-09 09:14:13 +00:00
|
|
|
fi
|
|
|
|
;;
|
2004-09-09 09:21:05 +00:00
|
|
|
condrestart)
|
|
|
|
[ -f /var/lock/subsys/nfslock ] && {
|
|
|
|
stop
|
|
|
|
start
|
2008-07-02 23:35:53 +00:00
|
|
|
RETVAL=$?
|
|
|
|
}
|
|
|
|
;;
|
|
|
|
condstop)
|
|
|
|
[ -f /var/lock/subsys/nfslock ] && {
|
|
|
|
stop
|
|
|
|
RETVAL=$?
|
2004-09-09 09:21:05 +00:00
|
|
|
}
|
|
|
|
;;
|
2004-09-09 09:14:13 +00:00
|
|
|
*)
|
2008-07-02 23:35:53 +00:00
|
|
|
echo $"Usage: $0 {start|stop|status|restart|probe|condrestart|condstop}"
|
2007-07-30 10:10:07 +00:00
|
|
|
RETVAL=3
|
|
|
|
;;
|
2004-09-09 09:14:13 +00:00
|
|
|
esac
|
|
|
|
|
2007-05-16 17:34:55 +00:00
|
|
|
exit $RETVAL
|