From 4f2a98ca61425dca4af64faa5adea07d64dfa940 Mon Sep 17 00:00:00 2001 From: Polynomialdivision Date: Wed, 5 Feb 2025 18:35:16 +0100 Subject: [PATCH] scripts: use SSH connection check instead of ping for host verification To run the mass update script, you must be connected to the internal mesh network. If you're not connected, the script will report that routers or access points cannot be found. However, many users connect via proxy jumps through our gateways to manage devices via SSH. In its current state, the script relies on ping to verify connectivity, which fails when SSH access is possible but ping is not working. This update changes the script to check for an active SSH connection instead of relying on ping. This ensures that the SSH daemon is up and reachable, providing a more accurate verification of host availability, rather than just testing for ICMP echo requests. --- mass-update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mass-update.sh b/mass-update.sh index e88c4d43..a8874abb 100755 --- a/mass-update.sh +++ b/mass-update.sh @@ -60,7 +60,7 @@ fi # Function to check reachability check_reachability() { local hostname="$1" - if ping -4 -c 1 "$hostname" >/dev/null 2>&1 || ping -6 -c 1 "$hostname" >/dev/null 2>&1; then + if ssh -q -o StrictHostKeyChecking=no -o BatchMode=yes -o ConnectTimeout=5 "root@$hostname" exit >/dev/null 2>&1; then return 0 else return 1