summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2023-05-04 09:40:02 -0400
committerAndrew Cady <d@jerkface.net>2023-05-04 09:40:50 -0400
commit77e7306c4f049599ba60391586eb517a69ffe3dd (patch)
tree9ed5b06756259824d96c92033c6802f3cbef7eb3
parentc145dc507c59863588608fddf98f1a9175d170bc (diff)
pingwatch: handle "Address unreachable" properlyHEADmaster
-rwxr-xr-xdot/local/bin/pingwatch23
1 files changed, 18 insertions, 5 deletions
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 @@
1#!/bin/bash 1#!/bin/bash
2loud= 2loud=${VERBOSE}
3target=${1:-2601:401:8200:2d4c:c6a5:6c8c:1304:bcf7} 3default_target=marble.tj5tzswz7isfavggdjsiwxdjswrg6tadlzuf3j3q.ed25519.cryptonomic.net
4
5if [ $# = 1 ]
6then
7 target=$1
8else
9 target=$(dig -taaaa +short +answer $default_target || echo 2601:401:8200:2d4c:84f4:6bdc:963c:fde2)
10fi
11
12if [ "$VERBOSE" ]
13then
14 echo "target: $target" >&2
15fi
16
4 17
5process() 18process()
6{ 19{
@@ -9,13 +22,13 @@ process()
9 do 22 do
10 if read -t 5 line 23 if read -t 5 line
11 then 24 then
25 case "$line" in
26 'PING'* | *'Address unreachable') continue ;;
27 esac
12 if [ "$loud" ] 28 if [ "$loud" ]
13 then 29 then
14 printf '%s\n' "$line" 30 printf '%s\n' "$line"
15 fi 31 fi
16 case "$line" in
17 PING*) continue ;;
18 esac
19 if [ "$state" = on ] 32 if [ "$state" = on ]
20 then 33 then
21 continue 34 continue