Update .local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_before_91-configure-gpg.tmpl, .local/share/chezmoi/home/.chezmoiscripts/universal/run_once_before_decrypt-age-key.tmpl

This commit is contained in:
Brian Zalewski 2022-11-30 08:45:17 +00:00
parent d1365ad1dd
commit a2ed760fb4
2 changed files with 13 additions and 6 deletions

View file

@ -2,8 +2,8 @@
XDG_CONFIG_HOME="$HOME/.config"
if [ ! -f "${XDG_CONFIG_HOME}/age/chezmoi.txt" ]; then
mkdir -p "${XDG_CONFIG_HOME}/age"
age --decrypt --output "${XDG_CONFIG_HOME}/age/chezmoi.txt" "{{ .chezmoi.sourceDir }}/chezmoi.txt.age"
chmod 600 "${XDG_CONFIG_HOME}/age/chezmoi.txt"
fi
#if [ ! -f "${XDG_CONFIG_HOME}/age/chezmoi.txt" ]; then
# mkdir -p "${XDG_CONFIG_HOME}/age"
# age --decrypt --output "${XDG_CONFIG_HOME}/age/chezmoi.txt" "{{ .chezmoi.sourceDir }}/chezmoi.txt.age"
# chmod 600 "${XDG_CONFIG_HOME}/age/chezmoi.txt"
#fi

View file

@ -20,7 +20,14 @@ if [ -n "$KEYID" ] && command -v gpg > /dev/null; then
KEYID_TRIMMED="$(echo "$KEYID" | sed 's/^0x//')"
if ! gpg --list-secret-keys --keyid-format=long | grep "$KEYID_TRIMMED" > /dev/null; then
logg info 'Attempting to download the specified public GPG key (`{{ .user.gpg.id }}`) from public keyservers'
gpg --recv "$KEYID"
gpg --recv "$KEYID" || EXIT_CODE=$?
if [ -n "$EXIT_CODE" ]; then
logg warn 'Error downloading public GPG key'
logg info 'Retrying after turning on debug mode and using the standard DNS resolver'
sudo pkill dirmngr
dirmngr --debug-all --daemon --standard-resolver
gpg --recv "$KEYID"
fi
else
logg info 'Key is already in keyring'
fi