diff options
author | Andrew Cady <d@jerkface.net> | 2023-04-30 15:21:00 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2023-04-30 15:21:00 -0400 |
commit | 691c411e9a5eb7470a602aa1f9122d6f9a1b89df (patch) | |
tree | 020c6c3f2d11fe50b425cc5ef97ccda97d18ee70 | |
parent | ea405c08a6f062eb58219a6a1a177feb470dd8ee (diff) |
commit old changes from work tree
-rwxr-xr-x | ssh-check | 25 |
1 files changed, 19 insertions, 6 deletions
@@ -18,13 +18,23 @@ quietly() | |||
18 | "$@" </dev/null >/dev/null 2>&1 | 18 | "$@" </dev/null >/dev/null 2>&1 |
19 | } | 19 | } |
20 | 20 | ||
21 | c () | 21 | match() |
22 | { | ||
23 | local search_text="$1" search_pattern | ||
24 | shift | ||
25 | for search_pattern in "$@" | ||
26 | do | ||
27 | case "$search_text" in | ||
28 | $search_pattern) return ;; | ||
29 | esac | ||
30 | done | ||
31 | false | ||
32 | } | ||
33 | |||
34 | main() | ||
22 | { | 35 | { |
23 | local h hosts | 36 | local h hosts |
24 | $read_all -r hosts < "$CFG_FILE" | 37 | $read_all -r hosts < "$CFG_FILE" |
25 | if [ $# = 0 ]; then | ||
26 | set -- -4 | ||
27 | fi | ||
28 | host_field_width=1 | 38 | host_field_width=1 |
29 | for h in $hosts | 39 | for h in $hosts |
30 | do | 40 | do |
@@ -37,6 +47,8 @@ c () | |||
37 | { | 47 | { |
38 | for h in $hosts | 48 | for h in $hosts |
39 | do | 49 | do |
50 | [ $# = 0 ] || match "$h" "$@" || continue | ||
51 | |||
40 | ( if uptime=$(ssh $SSH_OPTIONS -n "$h" -- uptime 2>/dev/null) | 52 | ( if uptime=$(ssh $SSH_OPTIONS -n "$h" -- uptime 2>/dev/null) |
41 | then | 53 | then |
42 | printf "%-15s %-${host_field_width}s %s\n" "Succeeded:" "$h" "${uptime# }" | 54 | printf "%-15s %-${host_field_width}s %s\n" "Succeeded:" "$h" "${uptime# }" |
@@ -74,7 +86,8 @@ do | |||
74 | --edit) do_edit=y;; | 86 | --edit) do_edit=y;; |
75 | --run) run_anyway=y;; | 87 | --run) run_anyway=y;; |
76 | --) shift; break;; | 88 | --) shift; break;; |
77 | *) exit 1 ;; | 89 | -*) exit 1 ;; |
90 | *) break;; | ||
78 | esac | 91 | esac |
79 | shift | 92 | shift |
80 | done | 93 | done |
@@ -92,4 +105,4 @@ then | |||
92 | edit_config | 105 | edit_config |
93 | fi | 106 | fi |
94 | 107 | ||
95 | c "$@" | 108 | main "$@" |