diff options
author | Christian Pointner <equinox@spreadspace.org> | 2018-12-01 23:14:05 +0100 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2018-12-01 23:14:05 +0100 |
commit | 17447210485bbe379beb9c7e9a3034e900110ed9 (patch) | |
tree | 1b911eed4ea5bce52a5bc24f0951dfe200ea3217 /gpg/create-environment.sh | |
parent | fixed acmetool self-signed cert handling (diff) |
moved to multi environment repo structure
Diffstat (limited to 'gpg/create-environment.sh')
-rwxr-xr-x | gpg/create-environment.sh | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/gpg/create-environment.sh b/gpg/create-environment.sh new file mode 100755 index 00000000..7ee5827b --- /dev/null +++ b/gpg/create-environment.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +if [ -z "$1" ]; then + echo "Usage: $0 <environment> [ <keyfile> ]" + exit 1 +fi +NAME="$1" +shift + +if [ -e "${BASH_SOURCE%/*}/get-vault-pass-$NAME" ]; then + echo "environment '$NAME' already exists." + exit 0 +fi + + +if [ -z "$1" ]; then + echo "no keyfile specified, reading from stdin ..." +fi + +"${BASH_SOURCE%/*}/gpg2.sh" "$NAME" --import "$@" +if [ $? -ne 0 ]; then + echo -e "\nERROR: importing key(s) failed." + exit 1 +fi + + +### enable this as soon https://github.com/ansible/ansible/issues/18319 has landed +#ln -s get-vault-pass- "${BASH_SOURCE%/*}/get-vault-pass-$NAME" +cp "${BASH_SOURCE%/*}/get-vault-pass-" "${BASH_SOURCE%/*}/get-vault-pass-$NAME" + +echo "" +echo "Please type in passphrase:" +"${BASH_SOURCE%/*}/set-vault-pass.sh" "$NAME" +if [ $? -ne 0 ]; then + echo -e "\nERROR: creating vault password file failed!" + exit 1 +fi +echo "" +echo "Successfully created vault password file!" +echo " Don't forget to commit gpg/get-vault-pass-$NAME, gpg/vault-pass-$NAME.gpg and gpg/vault-keyring-$NAME.gpg." |