summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2023-04-30 15:50:21 -0400
committerAndrew Cady <d@jerkface.net>2023-04-30 15:50:21 -0400
commitad4d6a06f32382b0417fe87cbb8afb420758130a (patch)
treed1af93711019007e741aaaf1b5d29e89b545873d
parent980715b4bab07c7602aaa50ef6f35daf17604a24 (diff)
add more options
-rwxr-xr-xssh-check14
1 files changed, 12 insertions, 2 deletions
diff --git a/ssh-check b/ssh-check
index df5274b..5045bb1 100755
--- a/ssh-check
+++ b/ssh-check
@@ -49,7 +49,7 @@ main()
49 do 49 do
50 [ $# = 0 ] || match "$h" "$@" || continue 50 [ $# = 0 ] || match "$h" "$@" || continue
51 51
52 ( if uptime=$(ssh $SSH_OPTIONS -n "$h" -- uptime 2>/dev/null) 52 ( if uptime=$(ssh $SSH_OPTIONS -n "$h" -- ${REMOTE_COMMAND:-uptime} 2>/dev/null)
53 then 53 then
54 printf "%-15s %-${host_field_width}s %s\n" "Succeeded:" "$h" "${uptime# }" 54 printf "%-15s %-${host_field_width}s %s\n" "Succeeded:" "$h" "${uptime# }"
55 else 55 else
@@ -79,14 +79,24 @@ edit_config()
79 rm "$f".timestamp 79 rm "$f".timestamp
80} 80}
81 81
82usage()
83{
84 cat <<EOF
85Usage: $0 [--help | -h] [--verbose | -v] [--edit] [--run] [--] [host pattern] [...]
86EOF
87}
88
82unset run_anyway do_edit 89unset run_anyway do_edit
83while [ $# -gt 0 ] 90while [ $# -gt 0 ]
84do 91do
85 case "$1" in 92 case "$1" in
86 --edit) do_edit=y;; 93 --edit) do_edit=y;;
87 --run) run_anyway=y;; 94 --run) run_anyway=y;;
95 --help | -h) usage; exit;;
96 --command) REMOTE_COMMAND=$2; shift 2;;
97 --verbose | -v) VERBOSE=y; shift;;
88 --) shift; break;; 98 --) shift; break;;
89 -*) exit 1 ;; 99 -*) usage >&2; exit 1 ;;
90 *) break;; 100 *) break;;
91 esac 101 esac
92 shift 102 shift