summaryrefslogtreecommitdiff
path: root/gpg/add-key.sh
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2018-12-01 23:14:05 +0100
committerChristian Pointner <equinox@spreadspace.org>2018-12-01 23:14:05 +0100
commit17447210485bbe379beb9c7e9a3034e900110ed9 (patch)
tree1b911eed4ea5bce52a5bc24f0951dfe200ea3217 /gpg/add-key.sh
parentfixed acmetool self-signed cert handling (diff)
moved to multi environment repo structure
Diffstat (limited to 'gpg/add-key.sh')
-rwxr-xr-xgpg/add-key.sh17
1 files changed, 12 insertions, 5 deletions
diff --git a/gpg/add-key.sh b/gpg/add-key.sh
index 98e29174..82970a91 100755
--- a/gpg/add-key.sh
+++ b/gpg/add-key.sh
@@ -1,21 +1,28 @@
#!/bin/bash
if [ -z "$1" ]; then
+ echo "Usage: $0 <environment> [ <keyfile> ]"
+ exit 1
+fi
+NAME="$1"
+shift
+
+if [ -z "$1" ]; then
echo "no keyfile specified, reading from stdin ..."
fi
-"${BASH_SOURCE%/*}/gpg2.sh" --import $@
+"${BASH_SOURCE%/*}/gpg2.sh" "$NAME" --import "$@"
if [ $? -ne 0 ]; then
- echo -e "\nERROR: import key(s) failed. Please revert any changes of the file gpg/vault-keyring.gpg."
+ echo -e "\nERROR: importing key(s) failed. Please revert any changes of the file gpg/vault-keyring-$NAME.gpg."
exit 1
fi
echo ""
-"${BASH_SOURCE%/*}/get-vault-pass.sh" | "${BASH_SOURCE%/*}/set-vault-pass.sh"
+"${BASH_SOURCE%/*}/get-vault-pass-$NAME" | "${BASH_SOURCE%/*}/set-vault-pass.sh" "$NAME"
if [ $? -ne 0 ]; then
echo -e "\nERROR: reencrypting vault password file failed!"
- echo " You might want to revert any changes on gpg/vault-pass.gpg and gpg/vault-keyring.gpg!!"
+ echo " You might want to revert any changes on gpg/vault-pass-$NAME.gpg and gpg/vault-keyring-$NAME.gpg!!"
exit 1
fi
echo "Successfully reencrypted vault password file!"
-echo " Don't forget to commit the changes in gpg/vault-pass.gpg and gpg/vault-keyring.gpg."
+echo " Don't forget to commit the changes in gpg/vault-pass-$NAME.gpg and gpg/vault-keyring-$NAME.gpg."