From 08fefed7f311d85881bfeb9974b1c76638b3fd24 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 24 Jan 2026 12:07:38 -0600 Subject: feat(email): add password decryption to setup script - Add password decryption loop to scripts/setup-email.sh - Decrypt .gpg files from assets/mail-passwords/ to ~/.config/ - Add encrypted password files (.gmailpass.gpg, .cmailpass.gpg) - Fix missing paren in text-config.el that broke config parsing - Clean up mail-config.el --- assets/mail-passwords/.cmailpass.gpg | Bin 0 -> 93 bytes assets/mail-passwords/.gmailpass.gpg | 1 + modules/mail-config.el | 18 ++++++++++-------- modules/text-config.el | 2 +- scripts/setup-email.sh | 35 +++++++++++++++++++++++++++++++++++ 5 files changed, 47 insertions(+), 9 deletions(-) create mode 100644 assets/mail-passwords/.cmailpass.gpg create mode 100644 assets/mail-passwords/.gmailpass.gpg diff --git a/assets/mail-passwords/.cmailpass.gpg b/assets/mail-passwords/.cmailpass.gpg new file mode 100644 index 00000000..2c9c1954 Binary files /dev/null and b/assets/mail-passwords/.cmailpass.gpg differ diff --git a/assets/mail-passwords/.gmailpass.gpg b/assets/mail-passwords/.gmailpass.gpg new file mode 100644 index 00000000..cea3fe17 --- /dev/null +++ b/assets/mail-passwords/.gmailpass.gpg @@ -0,0 +1 @@ +Œ  ¨‘q~–¤9KÿÒEp…é[,/Fd?aNTÒ†o%#JWÙ-«•‚rsšW_£ídíMïG¾>Óv³ª£õÃ~Bñzô²W[˜hQ°r \ No newline at end of file diff --git a/modules/mail-config.el b/modules/mail-config.el index 170711bb..28423f52 100644 --- a/modules/mail-config.el +++ b/modules/mail-config.el @@ -47,19 +47,21 @@ Prompts user for the action when executing." ;; --------------------------------- Mu4e Email -------------------------------- +(autoload 'mu4e "mu4e" "Launch mu4e email client." t) +(keymap-global-set "C-c m" #'mu4e) + (use-package mu4e :ensure nil ;; mu4e gets installed by installing 'mu' via the system package manager :load-path "/usr/share/emacs/site-lisp/mu4e/" :commands (mu4e mu4e-update-index) :bind - ("C-c m". mu4e) - (:map mu4e-headers-mode-map - ("M" . cj/mu4e-mark-all-headers) - ("D" . mu4e-headers-mark-for-trash) - ("d" . mu4e-headers-mark-for-delete)) - (:map mu4e-view-mode-map - ("r" . mu4e-compose-wide-reply) - ("R" . mu4e-compose-reply)) + ((:map mu4e-headers-mode-map + ("M" . cj/mu4e-mark-all-headers) + ("D" . mu4e-headers-mark-for-trash) + ("d" . mu4e-headers-mark-for-delete)) + (:map mu4e-view-mode-map + ("r" . mu4e-compose-wide-reply) + ("R" . mu4e-compose-reply))) :hook (mu4e-view-mode . turn-on-visual-line-mode) :config diff --git a/modules/text-config.el b/modules/text-config.el index 30f63aa2..4e9208bc 100644 --- a/modules/text-config.el +++ b/modules/text-config.el @@ -60,7 +60,7 @@ ;; edit selection in new buffer, C-c to finish; replaces with modifications (use-package edit-indirect - :bind ("M-S-i" . edit-indirect-region) ;; was M-I) + :bind ("M-S-i" . edit-indirect-region)) ;; was M-I ;; ------------------------------ Prettify Symbols ----------------------------- ;; replacing the word l-a-m-b-d-a with a symbol, just because diff --git a/scripts/setup-email.sh b/scripts/setup-email.sh index 7607eb61..9cb23294 100755 --- a/scripts/setup-email.sh +++ b/scripts/setup-email.sh @@ -2,6 +2,7 @@ # Craig Jennings # Typically run on a fresh installation on a new machine. +# - Decrypts mail passwords from encrypted .gpg files to ~/.config/ # - Validates all email components of my Emacs email setup are in place # - Validates local email directories exist; creates them if they don't exist # - Performs initial email sync to local directories @@ -9,6 +10,11 @@ set -euo pipefail +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +EMACS_DIR="$(dirname "$SCRIPT_DIR")" +ENCRYPTED_PASSWORDS_DIR="$EMACS_DIR/assets/mail-passwords" +PASSWORD_DEST_DIR="$HOME/.config" + MBSYNC="$(command -v mbsync || true)" MU="$(command -v mu || true)" MU4EDIR="/usr/share/emacs/site-lisp/mu4e" @@ -20,6 +26,35 @@ MAILROOT="$HOME/.mail" GMAILDIR="$MAILROOT/gmail" CMAILDIR="$MAILROOT/cmail" +# Decrypt Mail Passwords +# Loop through all .gpg files in assets/mail-passwords/ +# Skip if destination already exists, decrypt if missing +echo "→ checking mail passwords..." +if [[ -d "$ENCRYPTED_PASSWORDS_DIR" ]]; then + for gpg_file in "$ENCRYPTED_PASSWORDS_DIR"/*.gpg; do + [[ -f "$gpg_file" ]] || continue # Skip if no .gpg files + + filename=$(basename "$gpg_file") + dest_file="$PASSWORD_DEST_DIR/${filename%.gpg}" # Strip .gpg extension + + if [[ -f "$dest_file" ]]; then + echo " ✓ $dest_file already exists, skipping" + else + echo " → decrypting $filename..." + if gpg -q -d "$gpg_file" > "$dest_file" 2>/dev/null; then + chmod 600 "$dest_file" + echo " ✓ created $dest_file" + else + echo " ✗ failed to decrypt $filename" + rm -f "$dest_file" # Clean up partial file + exit 1 + fi + fi + done +else + echo " âš  encrypted passwords directory not found: $ENCRYPTED_PASSWORDS_DIR" +fi + # Check All Prerequisites [[ -x "$MBSYNC" ]] || { echo "ERROR: mbsync not found. Install 'isync'."; exit 1; } [[ -x "$MU" ]] || { echo "ERROR: mu not found. Install 'mu'."; exit 1; } -- cgit v1.2.3