From 77e7306c4f049599ba60391586eb517a69ffe3dd Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Thu, 4 May 2023 09:40:02 -0400 Subject: pingwatch: handle "Address unreachable" properly --- dot/local/bin/pingwatch | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'dot') diff --git a/dot/local/bin/pingwatch b/dot/local/bin/pingwatch index a67d014..c487c2f 100755 --- a/dot/local/bin/pingwatch +++ b/dot/local/bin/pingwatch @@ -1,6 +1,19 @@ #!/bin/bash -loud= -target=${1:-2601:401:8200:2d4c:c6a5:6c8c:1304:bcf7} +loud=${VERBOSE} +default_target=marble.tj5tzswz7isfavggdjsiwxdjswrg6tadlzuf3j3q.ed25519.cryptonomic.net + +if [ $# = 1 ] +then + target=$1 +else + target=$(dig -taaaa +short +answer $default_target || echo 2601:401:8200:2d4c:84f4:6bdc:963c:fde2) +fi + +if [ "$VERBOSE" ] +then + echo "target: $target" >&2 +fi + process() { @@ -9,13 +22,13 @@ process() do if read -t 5 line then + case "$line" in + 'PING'* | *'Address unreachable') continue ;; + esac if [ "$loud" ] then printf '%s\n' "$line" fi - case "$line" in - PING*) continue ;; - esac if [ "$state" = on ] then continue -- cgit v1.2.3