Now vaguely tested initscript updates.
[metze/samba/wip.git] / ctdb / config / events.d / 01.reclock
1 #!/bin/sh
2 # script to check accessibility to the reclock file on a node
3
4 . $CTDB_BASE/functions
5 loadconfig
6
7 case $cmd in 
8     startup)
9         ctdb_counter_init
10         ;;
11     
12     monitor)
13         RECLOCKFILE=$(ctdb -Y getreclock)
14
15         ctdb_counter_incr
16         (ctdb_check_counter_limit 200 >/dev/null 2>&1) || {
17             echo "Reclock file $RECLOCKFILE\" can not be accessed. Shutting down."
18             df
19             sleep 1
20             ctdb shutdown
21         }
22
23         [ -z "$RECLOCKFILE" ] && {
24             # we are not using a reclock file
25             ctdb_counter_init
26             exit 0
27         }
28
29         # try stat the reclock file as a background process
30         # so that we dont block in case the cluster filesystem is unavailable
31         (
32             stat $RECLOCKFILE && {
33                 # we could stat the file, reset the counter
34                 ctdb_counter_init
35             }
36         ) >/dev/null 2>/dev/null &
37
38         ctdb_check_counter_limit 3 quiet
39         ;;
40     status)
41         ctdb_checkstatus || exit $?
42         ;;
43 esac
44
45 exit 0