summaryrefslogtreecommitdiff
path: root/gpg
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2020-05-03 04:31:33 +0200
committerChristian Pointner <equinox@spreadspace.org>2020-05-03 04:31:33 +0200
commite586d6beeb43f9b0d8dba5dd3d3be805866b0242 (patch)
tree773ab7b64cec2182f0ce60326a7412b02b2401c1 /gpg
parentmove apt-repo/kubernetes out of kubernetes base role (diff)
gpg: add autodetection for binary
Diffstat (limited to 'gpg')
-rwxr-xr-xgpg/get-vault-pass.sh7
-rwxr-xr-xgpg/gpg2.sh7
2 files changed, 12 insertions, 2 deletions
diff --git a/gpg/get-vault-pass.sh b/gpg/get-vault-pass.sh
index 6cf2ff9a..5c295fd0 100755
--- a/gpg/get-vault-pass.sh
+++ b/gpg/get-vault-pass.sh
@@ -6,7 +6,12 @@ fi
NAME="$1"
shift
-gpg2 --decrypt --batch --no-tty --quiet < "${BASH_SOURCE%/*}/vault-pass-$NAME.gpg"
+BIN=$(which gpg2)
+if [ $? -ne 0 ]; then
+ BIN=$(which gpg)
+fi
+
+$BIN --decrypt --batch --no-tty --quiet < "${BASH_SOURCE%/*}/vault-pass-$NAME.gpg"
# Ansible up to including 2.6 seems to have a bug which ignores the setting of 'vault_id_match = True'
# in ansible.cfg (or the equivalent environment variable).
diff --git a/gpg/gpg2.sh b/gpg/gpg2.sh
index 4e4cbaae..1292b709 100755
--- a/gpg/gpg2.sh
+++ b/gpg/gpg2.sh
@@ -7,4 +7,9 @@ fi
NAME="$1"
shift
-exec gpg2 --keyring "${BASH_SOURCE%/*}/vault-keyring-$NAME.gpg" --secret-keyring /dev/null --no-options --no-default-keyring --trust-model always --keyid-format 0xlong "$@"
+BIN=$(which gpg2)
+if [ $? -ne 0 ]; then
+ BIN=$(which gpg)
+fi
+
+exec $BIN --keyring "${BASH_SOURCE%/*}/vault-keyring-$NAME.gpg" --secret-keyring /dev/null --no-options --no-default-keyring --trust-model always --keyid-format 0xlong "$@"