summaryrefslogtreecommitdiff
path: root/tests/try-ssh.sh
blob: 109299bc3e9e3564ba9db372117b850010cdc915 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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