From 35f89c0ca5276c3fa939e2cba92068ae1d123c11 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Sun, 29 Aug 2021 09:29:34 +0200 Subject: [PATCH] vm: More precise "free port" detection 22000 is used by syncthing, and it resets the connection. Specifically search for a refused connection. --- vm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm b/vm index 0f14fea..5323132 100755 --- a/vm +++ b/vm @@ -5,7 +5,7 @@ image="$1" shift # determine ssh forward port ssh_port=22000 -while echo '' | nc localhost $ssh_port >/dev/null; do +until echo '' | nc localhost $ssh_port 2>&1 >/dev/null | grep -q 'Connection refused'; do ssh_port=$((ssh_port+1)) done echo "Host ssh port: $ssh_port" -- 2.39.5