Created
June 12, 2017 23:46
-
-
Save wallentx/8d9158617d538534ea11cdba94413ced to your computer and use it in GitHub Desktop.
Vault Auth and Server wrapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # This assumes that the vault binary is within your PATH | |
| # Set vault server | |
| export VAULT_ADDR=https://your.vault.server | |
| # Set auth method. E.g. - GitHub Token | |
| GITHUB_TOKEN=$(cat /path/to/github/token/file) | |
| if [[ ! -f ~/.vault-token ]]; then | |
| echo "Connecting to "$VAULT_ADDR"..." | |
| vault auth -method=github token=$GITHUB_TOKEN || { | |
| printf '%s\n' 'Unable to authorize. Check your token or token path.' >&2 | |
| exit 1 | |
| } | |
| fi | |
| # Source Vault Completion | |
| # I can't seem to get this to work currently. It might not be possible | |
| [[ -f ~/bin/vault-completion ]] && . ~/bin/vault-completion | |
| vault $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment