blob: b07539fe4743fcefc0203d5e9843071a137072d6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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" "$NAME" --import "$@"
if [ $? -ne 0 ]; then
echo -e "\nERROR: importing key(s) failed. Please revert any changes of the file ${0%/*}/vault-keyring-$NAME.gpg."
exit 1
fi
echo ""
"${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 ${0%/*}/vault-pass-$NAME.gpg and ${0%/*}/vault-keyring-$NAME.gpg!!"
exit 1
fi
echo "Successfully reencrypted vault password file!"
echo " Don't forget to commit the changes in ${0%/*}/vault-pass-$NAME.gpg and ${0%/*}/vault-keyring-$NAME.gpg."
|