forked from LibertaCasa/salt-keydiff
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>
This commit is contained in:
parent
d30630d94f
commit
db343e31ce
18
salt-keydiff.sh
Normal file → Executable file
18
salt-keydiff.sh
Normal file → Executable file
@ -15,19 +15,19 @@ set -Ceu
|
|||||||
minion="${1:-null}"
|
minion="${1:-null}"
|
||||||
NOCOLOR="$(tput sgr0)"
|
NOCOLOR="$(tput sgr0)"
|
||||||
|
|
||||||
if [ "$minion" = 'null' ]
|
|
||||||
then
|
|
||||||
printf 'Please specify the minion to diff against.\n'
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! command -v jq >/dev/null || ! command -v salt-key >/dev/null
|
if ! command -v jq >/dev/null || ! command -v salt-key >/dev/null
|
||||||
then
|
then
|
||||||
printf 'Please ensure jq and salt-key are available.\n'
|
printf 'Please ensure jq and salt-key are available.\n'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
key_salt="$(salt-key --out json -f $minion | jq --arg minion $minion -r '.minions_pre[$minion]')"
|
if [ "$minion" = 'null' ]
|
||||||
|
then
|
||||||
|
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]')"
|
||||||
|
|
||||||
if [ "$key_salt" = 'null' ]
|
if [ "$key_salt" = 'null' ]
|
||||||
then
|
then
|
||||||
@ -35,8 +35,8 @@ then
|
|||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf 'Enter fingerprint to diff against\n'
|
printf 'Enter fingerprint to diff against (run `salt-call --local key.finger` on the minion)\n'
|
||||||
read key_user
|
read -r key_user
|
||||||
|
|
||||||
if [ "$key_salt" = "$key_user" ]
|
if [ "$key_salt" = "$key_user" ]
|
||||||
then
|
then
|
||||||
|
Loading…
Reference in New Issue
Block a user