summaryrefslogtreecommitdiffstats
path: root/base/root/scripts/functions
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2008-09-24 11:25:00 +1000
committerMartin Schwenke <martin@meltin.net>2008-09-24 11:25:00 +1000
commit65fd72d76d37cd0045671ac54369cf5e5d144ec5 (patch)
treebbc1c53cfb99f39fff8da9816491ab90badceec4 /base/root/scripts/functions
parent9c11380c25d9c80d31b4e1cfac0771ea3ee44ac7 (diff)
downloadautocluster-65fd72d76d37cd0045671ac54369cf5e5d144ec5.tar.gz
autocluster-65fd72d76d37cd0045671ac54369cf5e5d144ec5.tar.xz
autocluster-65fd72d76d37cd0045671ac54369cf5e5d144ec5.zip
Add base file /root/scripts/functions. setup_samba.sh now properly
waits for a completely healthy cluster. chroot jail generation goes after winbind start. We also no longer try to fix the jail - assume a working cnjailgen is hacked in via some other process. Signed-off-by: Martin Schwenke <martin@meltin.net>
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
+}