summaryrefslogtreecommitdiffstats
path: root/autocluster
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2014-06-27 11:45:49 +1000
committerMartin Schwenke <martin@meltin.net>2014-07-02 14:17:17 +1000
commitef72de0899d54d341ad8b9cb81e27ea27aa29bf8 (patch)
treefb7886b671a95a1ec390fa5c50ada15baacbddc8 /autocluster
parent0aa1c68a8fe6116b2867dc26bbccbb90e8f1fabd (diff)
downloadautocluster-ef72de0899d54d341ad8b9cb81e27ea27aa29bf8.tar.gz
autocluster-ef72de0899d54d341ad8b9cb81e27ea27aa29bf8.tar.xz
autocluster-ef72de0899d54d341ad8b9cb81e27ea27aa29bf8.zip
Replace external waitfor script with a function
Signed-off-by: Martin Schwenke <martin@meltin.net>
Diffstat (limited to 'autocluster')
-rwxr-xr-xautocluster25
1 files changed, 25 insertions, 0 deletions
diff --git a/autocluster b/autocluster
index f742848..3c8219f 100755
--- a/autocluster
+++ b/autocluster
@@ -96,6 +96,31 @@ announce ()
echo ""
}
+waitfor ()
+{
+ local file="$1"
+ local msg="$2"
+ local timeout="$3"
+
+ local tmpfile=$(mktemp)
+
+ cat <<EOF >"$tmpfile"
+spawn tail -n 10000 -f $file
+expect -timeout $timeout -re "$msg"
+EOF
+
+ export LANG=C
+ expect "$tmpfile"
+ rm -f "$tmpfile"
+
+ if ! grep -E "$msg" "$file" > /dev/null; then
+ echo "Failed to find \"$msg\" in \"$file\""
+ return 1
+ fi
+
+ return 0
+}
+
###############################
# Indirectly call a function named by ${1}_${2}