summaryrefslogtreecommitdiff
path: root/testing/hosts/default/usr/local/bin/expect-connection
diff options
context:
space:
mode:
Diffstat (limited to 'testing/hosts/default/usr/local/bin/expect-connection')
-rwxr-xr-xtesting/hosts/default/usr/local/bin/expect-connection27
1 files changed, 27 insertions, 0 deletions
diff --git a/testing/hosts/default/usr/local/bin/expect-connection b/testing/hosts/default/usr/local/bin/expect-connection
new file mode 100755
index 000000000..10a709255
--- /dev/null
+++ b/testing/hosts/default/usr/local/bin/expect-connection
@@ -0,0 +1,27 @@
+#!/bin/bash
+#
+# Wait until a given IPsec connection becomes available
+#
+# Params:
+# $1 - connection name
+# $2 - maximum time to wait in seconds, default is 5 seconds
+
+if [[ $# -lt 1 || $# -gt 2 ]]
+then
+ echo "invalid arguments"
+ exit 1
+fi
+
+secs=$2
+[ ! $secs ] && secs=5
+
+let steps=$secs*10
+for i in `seq 1 $steps`
+do
+ ipsec statusall 2>&1 | grep ^[[:space:]]*$1: >/dev/null
+ [ $? -eq 0 ] && exit 0
+ sleep 0.1
+done
+
+echo "Connection '$1' not available after $secs second(s)"
+exit 1