From 553a15f30d60ff7acf07908bb96dfb3220bf2d34 Mon Sep 17 00:00:00 2001 From: Brian Zalewski Date: Wed, 30 Nov 2022 08:57:45 +0000 Subject: [PATCH] Update .local/share/chezmoi/home/.chezmoiscripts/universal/run_once_before_decrypt-age-key.tmpl, .local/share/chezmoi/home/key.txt.age, .local/share/chezmoi/home/.chezmoi.yaml.tmpl --- .local/share/chezmoi/home/.chezmoi.yaml.tmpl | 12 ++++++------ .../run_once_before_decrypt-age-key.tmpl | 16 +++++++++++----- .../home/{chezmoi.txt.age => key.txt.age} | Bin 3 files changed, 17 insertions(+), 11 deletions(-) rename .local/share/chezmoi/home/{chezmoi.txt.age => key.txt.age} (100%) diff --git a/.local/share/chezmoi/home/.chezmoi.yaml.tmpl b/.local/share/chezmoi/home/.chezmoi.yaml.tmpl index cb2d292e..8a438dd9 100644 --- a/.local/share/chezmoi/home/.chezmoi.yaml.tmpl +++ b/.local/share/chezmoi/home/.chezmoi.yaml.tmpl @@ -118,12 +118,12 @@ {{- writeToStdout "Chezmoi is running in headless environment.\n" -}} {{- end -}} -# encryption: "age" -# age: -# identity: "{{ .chezmoi.homeDir }}/.config/age/chezmoi.txt" -# recipient: "age1necy24c4lzxheey4p2m8v4q000n442wyv47qc640ulyxx9l8dpesdqv7ey" -# gpg: -# recipient: "{{ $gpgKeyId }}" +encryption: "age" +age: + identity: "{{ .chezmoi.homeDir }}/.config/age/chezmoi.txt" + recipient: "age1necy24c4lzxheey4p2m8v4q000n442wyv47qc640ulyxx9l8dpesdqv7ey" +gpg: + recipient: "{{ $gpgKeyId }}" data: host: arch: "{{ .chezmoi.arch }}" diff --git a/.local/share/chezmoi/home/.chezmoiscripts/universal/run_once_before_decrypt-age-key.tmpl b/.local/share/chezmoi/home/.chezmoiscripts/universal/run_once_before_decrypt-age-key.tmpl index 8d52a97b..5974e5c9 100644 --- a/.local/share/chezmoi/home/.chezmoiscripts/universal/run_once_before_decrypt-age-key.tmpl +++ b/.local/share/chezmoi/home/.chezmoiscripts/universal/run_once_before_decrypt-age-key.tmpl @@ -2,8 +2,14 @@ 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" + echo "Press CTRL+C if you have not set up your encryption token yet" + age --decrypt --output "${XDG_CONFIG_HOME}/age/chezmoi.txt" "{{ .chezmoi.sourceDir }}/key.txt.age" || EXIT_CODE=$? + if [ -n "$EXIT_CODE" ]; then + echo "Proceeding without decrypting age encryption key stored at ~/.local/share/chezmoi/home/key.txt.age" + echo "To have Chezmoi handle your encryption (so you can store your private files publicly) take a look at https://www.chezmoi.io/user-guide/frequently-asked-questions/encryption/#how-do-i-configure-chezmoi-to-encrypt-files-but-only-request-a-passphrase-the-first-time-chezmoi-init-is-run" + else + chmod 600 "${XDG_CONFIG_HOME}/age/chezmoi.txt" + fi +fi diff --git a/.local/share/chezmoi/home/chezmoi.txt.age b/.local/share/chezmoi/home/key.txt.age similarity index 100% rename from .local/share/chezmoi/home/chezmoi.txt.age rename to .local/share/chezmoi/home/key.txt.age