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
|
2024-09-16 18:52:53 +00:00
|
|
|
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)
|
2024-09-16 18:52:53 +00:00
|
|
|
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
|