diff options
Diffstat (limited to 'dot/local')
-rwxr-xr-x | dot/local/bin/pingwatch | 23 |
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 |
2 | loud= | 2 | loud=${VERBOSE} |
3 | target=${1:-2601:401:8200:2d4c:c6a5:6c8c:1304:bcf7} | 3 | default_target=marble.tj5tzswz7isfavggdjsiwxdjswrg6tadlzuf3j3q.ed25519.cryptonomic.net |
4 | |||
5 | if [ $# = 1 ] | ||
6 | then | ||
7 | target=$1 | ||
8 | else | ||
9 | target=$(dig -taaaa +short +answer $default_target || echo 2601:401:8200:2d4c:84f4:6bdc:963c:fde2) | ||
10 | fi | ||
11 | |||
12 | if [ "$VERBOSE" ] | ||
13 | then | ||
14 | echo "target: $target" >&2 | ||
15 | fi | ||
16 | |||
4 | 17 | ||
5 | process() | 18 | process() |
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 |