argo-crypt/git-wrapper.sh

17 lines
483 B
Bash
Raw Normal View History

2024-09-16 18:28:13 +00:00
#!/bin/bash
2024-09-16 17:51:28 +00:00
$(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=$(HOME=/tmp/githome vault write -field=token auth/approle/login role_id="${VAULT_ROLE_ID}")
2024-09-16 17:51:28 +00:00
tmpfile=$(mktemp)
HOME=/tmp/githome vault read -field=key "secret/git-crypt/$(<.git-crypt-key)" | base64 -d >${tmpfile}
HOME=/tmp/githome git-crypt unlock ${tmpfile}
2024-09-16 17:51:28 +00:00
rm ${tmpfile}
fi
exit $EC