diff options
author | Georg Pfuetzenreuter | 2023-01-30 02:07:03 +0100 |
---|---|---|
committer | Georg Pfuetzenreuter | 2023-01-30 02:07:03 +0100 |
commit | db343e31ced646f69bf1868e6d14989ee8c7606a (patch) | |
tree | 8de2f8ac1cb93921676dcc8e745f1f50e8f874c1 | |
parent | d30630d94f57b360f4f0e420b91e1b8889c1ef6a (diff) | |
download | salt-keydiff-db343e31ced646f69bf1868e6d14989ee8c7606a.tar.gz salt-keydiff-db343e31ced646f69bf1868e6d14989ee8c7606a.tar.bz2 salt-keydiff-db343e31ced646f69bf1868e6d14989ee8c7606a.zip |
Combined update
- follow ShellCheck advice:
- use read -r
- quote variables inside command substitution
- move dependency check to the beginning
Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
-rwxr-xr-x[-rw-r--r--] | salt-keydiff.sh | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/salt-keydiff.sh b/salt-keydiff.sh index 92fb112..b4de6a9 100644..100755 --- a/salt-keydiff.sh +++ b/salt-keydiff.sh @@ -15,19 +15,19 @@ set -Ceu minion="${1:-null}" NOCOLOR="$(tput sgr0)" -if [ "$minion" = 'null' ] +if ! command -v jq >/dev/null || ! command -v salt-key >/dev/null then - printf 'Please specify the minion to diff against.\n' + printf 'Please ensure jq and salt-key are available.\n' exit 1 fi -if ! command -v jq >/dev/null || ! command -v salt-key >/dev/null +if [ "$minion" = 'null' ] then - printf 'Please ensure jq and salt-key are available.\n' + printf 'Please specify the minion to diff against.\n' exit 1 fi -key_salt="$(salt-key --out json -f $minion | jq --arg minion $minion -r '.minions_pre[$minion]')" +key_salt="$(salt-key --out json -f "$minion" | jq --arg minion "$minion" -r '.minions_pre[$minion]')" if [ "$key_salt" = 'null' ] then @@ -35,8 +35,8 @@ then exit 2 fi -printf 'Enter fingerprint to diff against\n' -read key_user +printf 'Enter fingerprint to diff against (run `salt-call --local key.finger` on the minion)\n' +read -r key_user if [ "$key_salt" = "$key_user" ] then |