diff options
author | Andrew Cady <d@jerkface.net> | 2021-10-10 05:43:51 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2021-10-10 05:43:51 -0400 |
commit | ac6292125bc088d3fba6cabe617f56e0b815c6df (patch) | |
tree | ad6b3ed3457cf2036c38143ad6fe2b47510bb583 | |
parent | a1d8dcce355eba64e784159bde906da5f89e2262 (diff) |
quiet option
-rwxr-xr-x | cryptonomic-vpn | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/cryptonomic-vpn b/cryptonomic-vpn index 1598877..8bc726c 100755 --- a/cryptonomic-vpn +++ b/cryptonomic-vpn | |||
@@ -42,20 +42,20 @@ Options: | |||
42 | EOF | 42 | EOF |
43 | } | 43 | } |
44 | 44 | ||
45 | |||
46 | # Default command line argument values. | 45 | # Default command line argument values. |
47 | NO_ACT=y | 46 | NO_ACT=y |
48 | REMOTE_KEY_TYPE=rsa | 47 | REMOTE_KEY_TYPE=rsa |
49 | LOCAL_KEY=ssh_host_rsa_key | 48 | LOCAL_KEY=ssh_host_rsa_key |
50 | 49 | ||
51 | die() { printf 'Error: %s\n' "$*" >&2; exit 1; } | 50 | die() { printf 'Error: %s\n' "$*" >&2; exit 1; } |
52 | warn() { printf 'Warning: %s\n' "$*" >&2; } | 51 | warn() { [ "$QUIET" ] || printf 'Warning: %s\n' "$*" >&2; } |
52 | notice() { [ "$QUIET" ] || printf 'Notice: %s\n' "$*" >&2; } | ||
53 | 53 | ||
54 | parse_options() | 54 | parse_options() |
55 | { | 55 | { |
56 | OPTS=$(getopt \ | 56 | OPTS=$(getopt \ |
57 | --options 'hynf' \ | 57 | --options 'hynfq' \ |
58 | --longoptions 'help,yes-act,no-act,remote-ip:,remote-name:,remote-key-type:,local-key:' \ | 58 | --longoptions 'help,yes-act,no-act,quiet,remote-ip:,remote-name:,remote-key-type:,local-key:' \ |
59 | -n connect-vpn \ | 59 | -n connect-vpn \ |
60 | -- "$@") | 60 | -- "$@") |
61 | eval set -- "$OPTS" | 61 | eval set -- "$OPTS" |
@@ -72,6 +72,7 @@ parse_options() | |||
72 | -h | --help ) help; exit;; | 72 | -h | --help ) help; exit;; |
73 | -y | --yes-act ) NO_ACT=;; | 73 | -y | --yes-act ) NO_ACT=;; |
74 | -n | --no-act ) NO_ACT=y;; | 74 | -n | --no-act ) NO_ACT=y;; |
75 | -q | --quiet ) QUIET=y;; | ||
75 | --remote-ip ) shift; REMOTE_IP=$1;; | 76 | --remote-ip ) shift; REMOTE_IP=$1;; |
76 | --remote-name ) shift; REMOTE_NAME=$1;; | 77 | --remote-name ) shift; REMOTE_NAME=$1;; |
77 | --remote-key-type ) shift; REMOTE_KEY_TYPE=$1;; | 78 | --remote-key-type ) shift; REMOTE_KEY_TYPE=$1;; |
@@ -290,7 +291,7 @@ find_known_ssh_host_rsa_key_by_name() | |||
290 | while read keytype key | 291 | while read keytype key |
291 | do | 292 | do |
292 | [ "$keytype" = "$keytype_wanted" ] || continue | 293 | [ "$keytype" = "$keytype_wanted" ] || continue |
293 | echo "Notice: found host key: $name $keytype $key" >&2 | 294 | notice "found host key: $name $keytype $key" |
294 | echo "$keytype $key" > "$target" | 295 | echo "$keytype $key" > "$target" |
295 | exit | 296 | exit |
296 | done | 297 | done |
@@ -305,9 +306,9 @@ install_remote_public_key() | |||
305 | 306 | ||
306 | if find_known_ssh_host_rsa_key_by_name "$t" "$REMOTE_NAME" | 307 | if find_known_ssh_host_rsa_key_by_name "$t" "$REMOTE_NAME" |
307 | then | 308 | then |
308 | echo "Notice: using host key from OpenSSH KnownHostsFiles for $REMOTE_NAME" >&2 | 309 | notice "using host key from OpenSSH KnownHostsFiles for $REMOTE_NAME" |
309 | else | 310 | else |
310 | echo "Notice: scanning the network for host keys for $REMOTE_NAME" >&2 | 311 | notice "scanning the network for host keys for $REMOTE_NAME" |
311 | ./ssh-update-host-keys "$REMOTE_NAME" || die ssh-update-host-keys | 312 | ./ssh-update-host-keys "$REMOTE_NAME" || die ssh-update-host-keys |
312 | find_known_ssh_host_rsa_key_by_name "$t" "$REMOTE_NAME" || die "could not find host rsa key for $REMOTE_NAME" | 313 | find_known_ssh_host_rsa_key_by_name "$t" "$REMOTE_NAME" || die "could not find host rsa key for $REMOTE_NAME" |
313 | fi | 314 | fi |