1
0
Fork 0
mirror of https://github.com/Mic92/sops-nix.git synced 2024-12-14 11:57:52 +00:00
sops-nix/pkgs/sops-shell-hook/sops-shell-hook.bash
Jörg Thalheim 8ccd9ba269
first commit
2020-07-06 07:31:57 +01:00

23 lines
557 B
Bash

_sopsAddKey() {
@gpg@ --quiet --import "$key"
local fpr
fpr=$(@gpg@ --with-fingerprint --with-colons --show-key "$key" \
| awk -F: '$1 == "fpr" { print $10;}')
export SOPS_PGP_FP=''${SOPS_PGP_FP}''${SOPS_PGP_FP:+','}$fpr
}
sopsShellHook() {
local key dir
for key in $sopsGPGKeys; do
_sopsAddKey "$key"
done
for dir in $sopsGPGKeyDirs; do
while IFS= read -r -d '' key; do
_sopsAddKey "$key"
done < <(find "$dir" -type f -name '*.asc' -print0)
done
}
if [ -z "${shellHook-}" ]; then
shellHook=sopsShellHook
fi