-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdeploy-plan.sh
executable file
·31 lines (27 loc) · 1010 Bytes
/
deploy-plan.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
#!/bin/bash
if ! [ -x "$(command -v wg)" ]; then
echo "ERROR: WireGuard is not installed." >&2
exit 1
fi
# Create keys
umask 077
mkdir -v keys
wg genkey | tee keys/server_privatekey | wg pubkey > keys/server_publickey
wg genkey | tee keys/router_privatekey | wg pubkey > keys/router_publickey
wg genkey | tee keys/phone_privatekey | wg pubkey > keys/phone_publickey
# Setup vars for Terraform interpolation
unset TF_VAR_SERVER_PRIVATEKEY
unset TF_VAR_SERVER_PUBLICKEY
unset TF_VAR_ROUTER_PRIVATEKEY
unset TF_VAR_ROUTER_PUBLICKEY
unset TF_VAR_PHONE_PRIVATEKEY
unset TF_VAR_PHONE_PUBLICKEY
export TF_VAR_SERVER_PRIVATEKEY=$(cat keys/server_privatekey)
export TF_VAR_SERVER_PUBLICKEY=$(cat keys/server_publickey)
export TF_VAR_ROUTER_PRIVATEKEY=$(cat keys/router_privatekey)
export TF_VAR_ROUTER_PUBLICKEY=$(cat keys/router_publickey)
export TF_VAR_PHONE_PRIVATEKEY=$(cat keys/phone_privatekey)
export TF_VAR_PHONE_PUBLICKEY=$(cat keys/phone_publickey)
# Deploy infrastructure
terraform init
terraform plan