summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2014-06-24 14:19:28 +1000
committerMartin Schwenke <martin@meltin.net>2014-07-02 14:17:17 +1000
commitafc0e11395909098571fd3c8a892058397852b82 (patch)
treea5027db32f2e9e6cc5efbbad2bcae90ccb995889
parent8b12ef828f5a90a7acdd65d6c190017723291231 (diff)
downloadautocluster-afc0e11395909098571fd3c8a892058397852b82.tar.gz
autocluster-afc0e11395909098571fd3c8a892058397852b82.tar.xz
autocluster-afc0e11395909098571fd3c8a892058397852b82.zip
Move wait_until_healthy() into setup_cluster.sh
... and remove functions file. Signed-off-by: Martin Schwenke <martin@meltin.net>
-rw-r--r--base/all/root/scripts/functions33
-rwxr-xr-xbase/all/root/scripts/setup_cluster.sh23
2 files changed, 20 insertions, 36 deletions
diff --git a/base/all/root/scripts/functions b/base/all/root/scripts/functions
deleted file mode 100644
index 69952a6..0000000
--- a/base/all/root/scripts/functions
+++ /dev/null
@@ -1,33 +0,0 @@
-# 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##:*:*:*1:}" != "$line" ] && 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
-}
diff --git a/base/all/root/scripts/setup_cluster.sh b/base/all/root/scripts/setup_cluster.sh
index cd2c9c5..66a27ca 100755
--- a/base/all/root/scripts/setup_cluster.sh
+++ b/base/all/root/scripts/setup_cluster.sh
@@ -9,7 +9,26 @@ auth_type="files"
conf_file="/root/scripts/nas.conf"
-. /root/scripts/functions
+wait_until_healthy ()
+{
+ local timeout="${1:-120}"
+
+ echo -n "Wait until healthy [<${timeout}] "
+
+ local count=0
+ while [ $count -lt $timeout ] ; do
+ if ctdb nodestatus all >/dev/null ; then
+ echo "[${count}]"
+ return 0
+ fi
+ echo -n "."
+ count=$(($count + 1))
+ sleep 1
+ done
+
+ echo "[TIMEOUT]"
+ return 1
+}
####################
# show program usage
@@ -93,13 +112,11 @@ onnode -p all "service ctdb restart"
# let's hit this with a big hammer...
for i in $(seq 1 5) ; do
- echo "Waiting until healthy"
wait_until_healthy 60 && break
echo "Nope, restart ctdb..."
onnode -p all "service ctdb restart"
done
-echo "Waiting for cluster to become healthy"
wait_until_healthy
echo "Setup done"