summaryrefslogtreecommitdiffstats
path: root/base/root/scripts/functions
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2008-10-07 09:51:52 +1100
committerAndrew Tridgell <tridge@samba.org>2008-10-07 09:51:52 +1100
commit62b59d8a7c46ed9a7bdca15e4336e1ccd0322533 (patch)
tree840b1cc5a2d200d53ae8e1545596738965f69ce2 /base/root/scripts/functions
parentd8337534f1ffd4597721c1519c8ab2b1320a5e20 (diff)
parentbc86c0a1d5c9f1daeffa7b96a40fe35d357b0017 (diff)
Merge commit 'svart/master'
Diffstat (limited to 'base/root/scripts/functions')
-rw-r--r--base/root/scripts/functions33
1 files changed, 33 insertions, 0 deletions
diff --git a/base/root/scripts/functions b/base/root/scripts/functions
new file mode 100644
index 0000000..be320fe
--- /dev/null
+++ b/base/root/scripts/functions
@@ -0,0 +1,33 @@
+# Hey Emacs, this is a -*- shell-script -*- In fact, it is bash! :-)
+
+cluster_is_healthy ()
+{(
+ set -o pipefail
+ { ctdb -Y status || return 1 ; } |
+ {
+ read x
+ count=0
+ while read line ; do
+ count=$(($count + 1))
+ [ "${line#:*:*:}" != "0:0:0:0:" ] && cat >/dev/null && return 1
+ done
+ [ $count -gt 0 ] && return $?
+ }
+)}
+
+wait_until_healthy ()
+{
+ local timeout="${1:-120}"
+
+ while [ $timeout -gt 0 ] ; do
+ if cluster_is_healthy ; then
+ echo .
+ return 0
+ fi
+ echo -n .
+ timeout=$(($timeout - 1))
+ sleep 1
+ done
+
+ return 1
+}