2009-09-28 14:06:40 +10:00
#!/bin/sh
# script to check accessibility to the reclock file on a node
2013-01-03 15:26:12 +11:00
[ -n "$CTDB_BASE" ] || \
export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
2009-09-28 14:06:40 +10:00
. $CTDB_BASE/functions
2009-11-19 15:00:17 +11:00
loadconfig
2009-09-28 14:06:40 +10:00
2016-02-16 16:39:40 +11:00
# If CTDB_RECOVERY_LOCK specifies a helper then exit because this
# script can't do anything useful.
case "$CTDB_RECOVERY_LOCK" in
!*) exit 0 ;;
esac
2013-08-02 15:49:06 +10:00
case "$1" in
2010-01-19 10:07:14 +01:00
init)
2009-11-19 15:00:17 +11:00
ctdb_counter_init
2015-05-20 04:19:09 +10:00
if [ -n "$CTDB_RECOVERY_LOCK" ] ; then
d=$(dirname "$CTDB_RECOVERY_LOCK")
mkdir -vp "$d"
fi
2009-09-28 14:06:40 +10:00
;;
2009-11-19 16:48:19 +11:00
2013-08-02 15:49:06 +10:00
monitor)
2013-04-30 15:16:44 +10:00
# Early exit if not using a reclock file
2013-08-02 15:49:06 +10:00
[ -n "$CTDB_RECOVERY_LOCK" ] || exit 0
2013-04-30 15:16:44 +10:00
2013-04-30 15:19:52 +10:00
# Try to stat the reclock file as a background process so that
# we don't block in case the cluster filesystem is unavailable
(
2013-08-02 15:49:06 +10:00
if stat $CTDB_RECOVERY_LOCK ; then
2013-04-30 15:19:52 +10:00
# We could stat the file, reset the counter
ctdb_counter_init
fi
) >/dev/null 2>&1 &
2009-11-19 15:00:17 +11:00
ctdb_counter_incr
2013-04-30 15:23:20 +10:00
if ! ctdb_check_counter "quiet" -ge 200 ; then
2013-08-02 15:49:06 +10:00
echo "Reclock file \"$CTDB_RECOVERY_LOCK\" can not be accessed. Shutting down."
2009-11-19 15:00:17 +11:00
df
sleep 1
ctdb shutdown
2013-04-30 15:23:20 +10:00
fi
2009-10-19 15:30:44 +11:00
2013-04-30 15:23:20 +10:00
ctdb_check_counter "error" -gt 3
2009-11-19 15:00:17 +11:00
;;
2009-12-01 17:43:47 +11:00
*)
ctdb_standard_event_handler "$@"
2009-09-28 14:06:40 +10:00
;;
esac
exit 0