From ac6292125bc088d3fba6cabe617f56e0b815c6df Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Sun, 10 Oct 2021 05:43:51 -0400 Subject: quiet option --- cryptonomic-vpn | 17 +++++++++-------- 1 file 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: EOF } - # Default command line argument values. NO_ACT=y REMOTE_KEY_TYPE=rsa LOCAL_KEY=ssh_host_rsa_key -die() { printf 'Error: %s\n' "$*" >&2; exit 1; } -warn() { printf 'Warning: %s\n' "$*" >&2; } +die() { printf 'Error: %s\n' "$*" >&2; exit 1; } +warn() { [ "$QUIET" ] || printf 'Warning: %s\n' "$*" >&2; } +notice() { [ "$QUIET" ] || printf 'Notice: %s\n' "$*" >&2; } parse_options() { OPTS=$(getopt \ - --options 'hynf' \ - --longoptions 'help,yes-act,no-act,remote-ip:,remote-name:,remote-key-type:,local-key:' \ + --options 'hynfq' \ + --longoptions 'help,yes-act,no-act,quiet,remote-ip:,remote-name:,remote-key-type:,local-key:' \ -n connect-vpn \ -- "$@") eval set -- "$OPTS" @@ -72,6 +72,7 @@ parse_options() -h | --help ) help; exit;; -y | --yes-act ) NO_ACT=;; -n | --no-act ) NO_ACT=y;; + -q | --quiet ) QUIET=y;; --remote-ip ) shift; REMOTE_IP=$1;; --remote-name ) shift; REMOTE_NAME=$1;; --remote-key-type ) shift; REMOTE_KEY_TYPE=$1;; @@ -290,7 +291,7 @@ find_known_ssh_host_rsa_key_by_name() while read keytype key do [ "$keytype" = "$keytype_wanted" ] || continue - echo "Notice: found host key: $name $keytype $key" >&2 + notice "found host key: $name $keytype $key" echo "$keytype $key" > "$target" exit done @@ -305,9 +306,9 @@ install_remote_public_key() if find_known_ssh_host_rsa_key_by_name "$t" "$REMOTE_NAME" then - echo "Notice: using host key from OpenSSH KnownHostsFiles for $REMOTE_NAME" >&2 + notice "using host key from OpenSSH KnownHostsFiles for $REMOTE_NAME" else - echo "Notice: scanning the network for host keys for $REMOTE_NAME" >&2 + notice "scanning the network for host keys for $REMOTE_NAME" ./ssh-update-host-keys "$REMOTE_NAME" || die ssh-update-host-keys find_known_ssh_host_rsa_key_by_name "$t" "$REMOTE_NAME" || die "could not find host rsa key for $REMOTE_NAME" fi -- cgit v1.2.3