CVE-2016-0771: tests/dns: Remove dependencies on env variables
[Samba.git] / ctdb / config / events.d / 01.reclock
blobd3dd612471f3b91b30452d488b05f26ad0b0f944
1 #!/bin/sh
2 # script to check accessibility to the reclock file on a node
4 [ -n "$CTDB_BASE" ] || \
5 export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
7 . $CTDB_BASE/functions
8 loadconfig
10 case "$1" in
11 init)
12 ctdb_counter_init
14 if [ -n "$CTDB_RECOVERY_LOCK" ] ; then
15 d=$(dirname "$CTDB_RECOVERY_LOCK")
16 mkdir -vp "$d"
20 monitor)
21 # Early exit if not using a reclock file
22 [ -n "$CTDB_RECOVERY_LOCK" ] || exit 0
24 # Try to stat the reclock file as a background process so that
25 # we don't block in case the cluster filesystem is unavailable
27 if stat $CTDB_RECOVERY_LOCK ; then
28 # We could stat the file, reset the counter
29 ctdb_counter_init
31 ) >/dev/null 2>&1 &
33 ctdb_counter_incr
34 if ! ctdb_check_counter "quiet" -ge 200 ; then
35 echo "Reclock file \"$CTDB_RECOVERY_LOCK\" can not be accessed. Shutting down."
37 sleep 1
38 ctdb shutdown
41 ctdb_check_counter "error" -gt 3
45 ctdb_standard_event_handler "$@"
47 esac
49 exit 0