summaryrefslogtreecommitdiff
path: root/tests/try-ssh.sh
diff options
context:
space:
mode:
authorJochen Sprickerhof <git@jochen.sprickerhof.de>2022-12-28 11:30:01 +0100
committerJochen Sprickerhof <git@jochen.sprickerhof.de>2022-12-28 21:37:56 +0100
commite08f30fe771d065a4cde8f58dd71b6d4a358004d (patch)
treeb60106359d996bf59a70303d545d6c1cedd20fe1 /tests/try-ssh.sh
parentc00b63fc4c642bec5be44577771170dc8b2ac5e0 (diff)
downloaddebvm-e08f30fe771d065a4cde8f58dd71b6d4a358004d.tar.gz
Extract ssh connection check to try-ssh.sh
Diffstat (limited to 'tests/try-ssh.sh')
-rwxr-xr-xtests/try-ssh.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/try-ssh.sh b/tests/try-ssh.sh
new file mode 100755
index 0000000..109299b
--- /dev/null
+++ b/tests/try-ssh.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+# shellcheck disable=SC2086
+
+if test "$#" -ne 2; then
+ echo "$(basename "$0") takes two positional arguments. options/host and command" 1>&2
+ exit 1
+fi
+
+timeout=5
+ts=$(sleepenh 0 || [ $? -eq 1 ])
+for i in $(seq 30); do
+ rv=0
+ ssh $1 echo success || rv=$?
+ test $rv -eq 0 && break
+ ts=$(sleepenh "$ts" "$timeout" || [ $? -eq 1 ]);
+ if test "$i" -eq 30; then
+ echo "timeout reached" >&2
+ exit 1
+ fi
+done
+ssh $1 $2