Fix gpg importer
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -1,12 +1,10 @@
|
|||||||
install -d -m 700 "$GNUPGHOME"
|
install -d -m 700 "$GNUPGHOME"
|
||||||
|
|
||||||
for dir in "$HOME"/.config/sops-nix/secrets/gpg/*; do
|
KEYS="$HOME/.config/sops-nix/secrets/gpg"
|
||||||
keyfile="$dir/key"
|
|
||||||
passfile="$dir/pass"
|
|
||||||
|
|
||||||
if [[ ! -f "$keyfile" ]]; then
|
import_key() {
|
||||||
continue
|
local keyfile="$1/key"
|
||||||
fi
|
local passfile="$1/pass"
|
||||||
|
|
||||||
if [[ -f "$passfile" ]]; then
|
if [[ -f "$passfile" ]]; then
|
||||||
gpg2 --batch --yes --pinentry-mode loopback --passphrase-file "$passfile" --import "$keyfile"
|
gpg2 --batch --yes --pinentry-mode loopback --passphrase-file "$passfile" --import "$keyfile"
|
||||||
@@ -14,10 +12,20 @@ for dir in "$HOME"/.config/sops-nix/secrets/gpg/*; do
|
|||||||
gpg2 --batch --yes --import "$keyfile"
|
gpg2 --batch --yes --import "$keyfile"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
gpg2 --with-colons --import-options show-only --import "$keyfile" | grep '^fpr' | cut -d: -f10 | while read -r key_id; do
|
gpg2 --with-colons --import-options show-only --import "$keyfile" \
|
||||||
echo "$key_id:6:" >> "$GNUPGHOME"/otrust.txt
|
| grep '^fpr' \
|
||||||
done
|
| cut -d: -f10 \
|
||||||
|
| while read -r key_id; do
|
||||||
|
echo "$key_id:6:" >> "$GNUPGHOME/otrust.txt"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ -f "$KEYS/key" ]]; then import_key "$KEYS"; fi
|
||||||
|
|
||||||
|
for dir in "$KEYS"/*; do
|
||||||
|
if [[ ! -d "$dir" ]]; then continue; fi
|
||||||
|
if [[ -f "$dir/key" ]]; then import_key "$dir"; fi
|
||||||
done
|
done
|
||||||
|
|
||||||
gpg2 --import-ownertrust "$GNUPGHOME"/otrust.txt
|
gpg2 --import-ownertrust "$GNUPGHOME/otrust.txt"
|
||||||
rm "$GNUPGHOME"/otrust.txt
|
rm "$GNUPGHOME/otrust.txt"
|
||||||
|
Reference in New Issue
Block a user