From 65fd72d76d37cd0045671ac54369cf5e5d144ec5 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Wed, 24 Sep 2008 11:25:00 +1000 Subject: 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 --- base/root/scripts/functions | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 base/root/scripts/functions (limited to 'base/root/scripts/functions') 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 +} -- cgit