1
0
Fork 0
mirror of https://github.com/Mic92/sops-nix.git synced 2024-12-15 17:50:51 +00:00
sops-nix/pkgs/sops-import-keys-hook/sops-import-keys-hook.bash
2022-11-02 17:09:40 +01:00

25 lines
652 B
Bash

sopsImportKeysHook() {
local key dir
if [ -n "${sopsCreateGPGHome}" ]; then
export GNUPGHOME=${sopsGPGHome:-$(pwd)/.git/gnupg}
mkdir -m 700 -p $GNUPGHOME
fi
for key in ${sopsPGPKeys-}; do
if [[ -f "$key" ]]; then
@gpg@ --quiet --import "$key"
else
echo "$key does not exists" >&2
fi
done
for dir in ${sopsPGPKeyDirs-}; do
while IFS= read -r -d '' key; do
@gpg@ --quiet --import "$key"
done < <(find -L "$dir" -type f \( -name '*.gpg' -o -name '*.asc' \) -print0)
done
}
if [ -z "${shellHook-}" ]; then
shellHook=sopsImportKeysHook
else
shellHook="sopsImportKeysHook;${shellHook}"
fi