-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.sh
executable file
·61 lines (44 loc) · 2.02 KB
/
setup.sh
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
VAULT_VERSION=${VAULT_VERSION:-1.7.1}
VAULT_ENTERPRISE=${VAULT_ENTERPRISE:-+ent}
VAULT_PORT=8200
INSTALLED=$(vault --version | awk '{print $2}' || echo "")
if [ -z "$INSTALLED" ] || [ "$INSTALLED" != "v${VAULT_VERSION}${VAULT_ENTERPRISE}" ]; then
set -ex
mkdir -p ${HOME}/bin/
curl -o /tmp/vault_${VAULT_VERSION}_linux_amd64.zip https://releases.hashicorp.com/vault/${VAULT_VERSION}${VAULT_ENTERPRISE}/vault_${VAULT_VERSION}${VAULT_ENTERPRISE}_linux_amd64.zip
unzip -d ${HOME}/bin/ -o /tmp/vault_${VAULT_VERSION}_linux_amd64.zip
sudo cp ${HOME}/bin/vault /usr/local/bin/
rm -f /tmp/vault_${VAULT_VERSION}_linux_amd64.zip
fi
TERRAFORM_VERSION=${TERRAFORM_VERSION:-0.15.1}
TF_INSTALLED=$(terraform --version| grep Terraform | awk '{print $2}' || echo "")
if [ -z "$TF_INSTALLED" ] || [ "$TF_INSTALLED" != "v${TERRAFORM_VERSION}" ]; then
mkdir -p ${HOME}/bin/
curl -o /tmp/terraform_${TERRAFORM_VERSION}_linux_amd64.zip https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip
unzip -d ${HOME}/bin/ -o /tmp/terraform_${TERRAFORM_VERSION}_linux_amd64.zip
rm -f /tmp/terraform_${TERRAFORM_VERSION}_linux_amd64.zip
fi
DOCKER_STATE=$(docker inspect -f '{{.State.Running}}' vault || echo 'false')
if [ $DOCKER_STATE != "true" ]; then
docker rm -f vault
docker pull hashicorp/vault-enterprise:${VAULT_VERSION}_ent
#docker pull -q vault:${VAULT_VERSION}
docker run \
-d \
--name vault \
-p 0.0.0.0:8200:8200 \
--cap-add=IPC_LOCK \
-e "VAULT_DEV_ROOT_TOKEN_ID=myroot" \
-e "VAULT_DEV_LISTEN_ADDRESS=0.0.0.0:${VAULT_PORT}" \
hashicorp/vault-enterprise:${VAULT_VERSION}_ent
fi
echo "export VAULT_ADDR=\"http://127.0.0.1:${VAULT_PORT}\"" > ${HOME}/.extra.vault
echo "export VAULT_TOKEN=myroot" >> ${HOME}/.extra.vault
source ${HOME}/.extra.vault
echo "=============="
terraform --version
echo "=============="
vault --version
echo "=============="
echo "now run: vault status"