Skip to content

Instantly share code, notes, and snippets.

@wallentx
Created June 12, 2017 23:46
Show Gist options
  • Select an option

  • Save wallentx/8d9158617d538534ea11cdba94413ced to your computer and use it in GitHub Desktop.

Select an option

Save wallentx/8d9158617d538534ea11cdba94413ced to your computer and use it in GitHub Desktop.
Vault Auth and Server wrapper
#!/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