(no commit message) master
authorChristian Weiske <cweiske@cweiske.de>
Fri, 7 Nov 2025 12:58:10 +0000 (13:58 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Fri, 7 Nov 2025 12:58:10 +0000 (13:58 +0100)
pingwait.sh [new file with mode: 0644]

diff --git a/pingwait.sh b/pingwait.sh
new file mode 100644 (file)
index 0000000..82e430e
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/bash\r
+# wait until a host is pingable, then exit\r
+\r
+ping_cancelled=false    # Keep track of whether the loop was cancelled, or succeeded\r
+until ping -c1 "$1" >/dev/null 2>&1; do :; done &    # The "&" backgrounds it\r
+trap "kill $!; ping_cancelled=true" SIGINT\r
+wait $!          # Wait for the loop to exit, one way or another\r
+trap - SIGINT    # Remove the trap, now we're done with it\r
+echo "Done pinging, cancelled=$ping_cancelled"\r