diff options
author | Jochen Sprickerhof <git@jochen.sprickerhof.de> | 2022-12-28 11:30:01 +0100 |
---|---|---|
committer | Jochen Sprickerhof <git@jochen.sprickerhof.de> | 2022-12-28 21:37:56 +0100 |
commit | e08f30fe771d065a4cde8f58dd71b6d4a358004d (patch) | |
tree | b60106359d996bf59a70303d545d6c1cedd20fe1 /tests | |
parent | c00b63fc4c642bec5be44577771170dc8b2ac5e0 (diff) | |
download | debvm-e08f30fe771d065a4cde8f58dd71b6d4a358004d.tar.gz |
Extract ssh connection check to try-ssh.sh
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/create-and-run.sh | 21 | ||||
-rwxr-xr-x | tests/try-ssh.sh | 22 |
2 files changed, 26 insertions, 17 deletions
diff --git a/tests/create-and-run.sh b/tests/create-and-run.sh index aafd41d..6e8e075 100755 --- a/tests/create-and-run.sh +++ b/tests/create-and-run.sh @@ -1,9 +1,7 @@ #!/bin/sh -# shellcheck disable=SC2086 - if test "$#" -ne 2; then - echo "$(basename $0) takes two positional arguments. architecture and release" 1>&2 + echo "$(basename "$0") takes two positional arguments. architecture and release" 1>&2 exit 1 fi @@ -19,18 +17,7 @@ ssh-keygen -f ssh_id -N '' debvm-create -k ssh_id.pub -o test.ext4 -a "$1" -r "$2" timeout 240s debvm-run -s 2222 -i test.ext4 & -timeout=5 -sshopt="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $(if test "$2" = jessie; then echo -o PubkeyAcceptedKeyTypes=+ssh-rsa; fi)" -ts=$(sleepenh 0 || [ $? -eq 1 ]) -for i in $(seq 30); do - rv=0 - ssh $sshopt -o ConnectTimeout="$timeout" -i ssh_id -p 2222 root@localhost 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 $sshopt -i ssh_id -p 2222 root@localhost poweroff +SSHOPT="-o ConnectTimeout=5 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" +test "$2" = jessie && SSHOPT="${SSHOPT} -o PubkeyAcceptedKeyTypes=+ssh-rsa" +tests/try-ssh.sh "$SSHOPT -i ssh_id -p 2222 root@localhost" poweroff wait 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 |