diff options
author | Christophe Lyon <christophe.lyon@linaro.org> | 2017-07-18 08:48:25 +0000 |
---|---|---|
committer | Christophe Lyon <christophe.lyon@linaro.org> | 2017-07-21 08:09:13 +0000 |
commit | 266f7da096eaa78f58db7aea18f300b52372ab8a (patch) | |
tree | 2990f7da1dc6227c1f9d3e4f4fa76b39c64f8df3 /jenkins-helpers.sh | |
parent | 35a1e0ff46962b2868619965eddf4c294004bcfa (diff) |
jenkins-helpers.sh: Add wait_for_ssh_server.
This new helper is used by start-container-docker.sh,
and will be used by other scripts later (for instance
by benchmarking scripts, to wait until a board has
rebooted).
Change-Id: I9853a2d1c0ae67df9bb3e90b65651d050c3e35f7
Diffstat (limited to 'jenkins-helpers.sh')
-rw-r--r-- | jenkins-helpers.sh | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/jenkins-helpers.sh b/jenkins-helpers.sh index c4080e7d..48d4724d 100644 --- a/jenkins-helpers.sh +++ b/jenkins-helpers.sh @@ -227,3 +227,31 @@ wget_wildcard_url () return $count ) } + +# Wait until the ssh server is ready to accept connexions +# $1: host +# $2: port +# $3: retry count (optional) +# Returns 0 on success, 1 in case of error +wait_for_ssh_server () +{ + local count=20 + local session_host="$1" + local session_port="$2" + + [ "x$3" != x ] && count="$3" + + while [ $count -gt 0 ] + do + ssh -p $session_port $session_host true && break + echo SSH server not ready, waiting..... + sleep 5 + count=$((count - 1)) + done + + if [ $count -eq 0 ]; then + echo "ERROR: SSH server did not respond ($session_host:$session_port)" + return 1 + fi + return 0 +} |