This commit is contained in:
Vassiliy Yegorov
2022-07-28 01:01:40 +07:00
parent b38288eba7
commit 2edf95fe70
3 changed files with 15 additions and 12 deletions

View File

@@ -1,12 +1,10 @@
apk add jq curl
export VAULT_ADDR=http://localhost:8200
root_token=$(cat /helpers/keys.json | jq -r '.root_token')
unseal_vault() {
export VAULT_TOKEN=$root_token
vault operator unseal -address=${VAULT_ADDR} $(cat /helpers/keys.json | jq -r '.keys[0]')
vault operator unseal -address=${VAULT_HOST} $(cat /helpers/keys.json | jq -r '.keys[0]')
vault login token=$VAULT_TOKEN
}
@@ -16,7 +14,7 @@ then
unseal_vault
else
echo "Vault not initialized"
curl -s --request POST --data '{"secret_shares": 1, "secret_threshold": 1}' http://${VAULT_ADDR}/v1/sys/init > /helpers/keys.json
curl -s --request POST --data '{"secret_shares": 1, "secret_threshold": 1}' ${VAULT_HOST}/v1/sys/init > /helpers/keys.json
root_token=$(cat /helpers/keys.json | jq -r '.root_token')
unseal_vault