Files
threshold/enos/modules/aws_vault/templates/vault-write-license.sh
T
Michael Li 333b9e855d chore(e2e): Use public version of enos (#4872)
* chore(e2e): Use public version of enos

* chore(e2e): Move vault module to this repo

terraform-enos-aws-vault is no longer supported
2024-06-10 11:13:09 -04:00

41 lines
842 B
Bash
Executable File

#!/bin/bash
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
license='${vault_license}'
if test $license = "none"; then
exit 0
fi
function retry {
local retries=$1
shift
local count=0
until "$@"; do
exit=$?
wait=$((2 ** count))
count=$((count + 1))
if [ "$count" -lt "$retries" ]; then
sleep "$wait"
else
return "$exit"
fi
done
return 0
}
export VAULT_ADDR=http://localhost:8200
export VAULT_TOKEN='${vault_root_token}'
# Temporary hack until we can make the unseal resource handle legacy license
# setting. If we're running 1.8 and above then we shouldn't try to set a license.
ver=$(${vault_bin_path} version)
if [[ "$(echo "$ver" |awk '{print $2}' |awk -F'.' '{print $2}')" -ge 8 ]]; then
exit 0
fi
retry 5 ${vault_bin_path} write /sys/license text="$license"