argo-crypt/git-wrapper.sh

16 lines
428 B
Bash
Raw Normal View History

2024-09-16 17:51:28 +00:00
#!/bin/sh
$(dirname $0)/git.bin "$@"
EC=$?
2024-09-16 18:18:37 +00:00
if [ "$1" = "checkout" -a -f ".git-crypt-key" -a ! "$GIT_CRYPT_RUNNING" = "true" ]; then
2024-09-16 17:51:28 +00:00
export GIT_CRYPT_RUNNING=true
export VAULT_TOKEN=$(vault write -field=token auth/approle/login role_id="${VAULT_ROLE_ID:-}")
tmpfile=$(mktemp)
vault read -field=key "secret/git-crypt/$(<.git-crypt-key)" | base64 -d >${tmpfile}
git-crypt unlock ${tmpfile}
rm ${tmpfile}
fi
exit $EC