forked from rboyer/devconsul
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvault.sh
More file actions
executable file
·34 lines (25 loc) · 738 Bytes
/
vault.sh
File metadata and controls
executable file
·34 lines (25 loc) · 738 Bytes
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
#!/bin/bash
set -euo pipefail
cd "$(dirname "$0")"
if ! command -v vault >/dev/null 2>&1 ; then
echo "ERROR: no 'vault' binary on PATH." >&2
exit 1
fi
readonly root_token_file=./cache/vault-token.val
vault_root_token() {
if [[ ! -f "${root_token_file}" ]]; then
echo "no vault root token defined in ${root_token_file}" >&2
exit 1
fi
local token
read -r token < "${root_token_file}"
# trim any whitespace; this overdoes it in the middle, but tokens don't have
# whitespace in the middle so :shrug:
echo "${token//[[:space:]]}"
}
export VAULT_ADDR="http://10.0.100.111:8200"
export VAULT_TOKEN="$(vault_root_token)"
if [[ -z "$VAULT_TOKEN" ]]; then
exit 1
fi
exec vault "$@"