Merge branch 'master' of ctdb into 'master' of samba
[sfrench/samba-autobuild/.git] / ctdb / config / events.d / 01.reclock
1 #!/bin/sh
2 # script to check accessibility to the reclock file on a node
3
4 [ -n "$CTDB_BASE" ] || \
5     export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
6
7 . $CTDB_BASE/functions
8 loadconfig
9
10 case "$1" in
11     init)
12         ctdb_counter_init
13         ;;
14
15     monitor)
16         # Early exit if not using a reclock file
17         [ -n "$CTDB_RECOVERY_LOCK" ] || exit 0
18
19         # Try to stat the reclock file as a background process so that
20         # we don't block in case the cluster filesystem is unavailable
21         (
22             if stat $CTDB_RECOVERY_LOCK ; then
23                 # We could stat the file, reset the counter
24                 ctdb_counter_init
25             fi
26         ) >/dev/null 2>&1 &
27
28         ctdb_counter_incr
29         if ! ctdb_check_counter "quiet" -ge 200 ; then
30             echo "Reclock file \"$CTDB_RECOVERY_LOCK\" can not be accessed. Shutting down."
31             df
32             sleep 1
33             ctdb shutdown
34         fi
35
36         ctdb_check_counter "error" -gt 3
37         ;;
38
39     *)
40         ctdb_standard_event_handler "$@"
41         ;;
42 esac
43
44 exit 0