aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-11 17:17:54 -0500
committerCraig Jennings <c@cjennings.net>2026-05-11 17:17:54 -0500
commiteddc103fd251e324f8bd5c9000ed8d29cb59c602 (patch)
treecbf158f83e625e78b328b50a714301d34f6351dc /scripts
parent7f353e925b7dbd6d0c16962e0e822aea0093308b (diff)
downloaddotemacs-eddc103fd251e324f8bd5c9000ed8d29cb59c602.tar.gz
dotemacs-eddc103fd251e324f8bd5c9000ed8d29cb59c602.zip
feat(setup-email): add the deepsat work account
`setup-email.sh' was still gmail+cmail only. Added `dmail' as a first-class maildir (`~/.mail/dmail') and the work address to the `mu init' list, and reworked password bootstrap to match the live config: the gmail and dmail password files stay encrypted (mbsync/msmtp decrypt them on use), while cmail decrypts to `~/.config/.cmailpass' for ProtonBridge. A missing password source now fails loudly instead of continuing silently. `bash -n' verified. The script itself wasn't run, since it decrypts credentials, runs mbsync, and reindexes mu.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/setup-email.sh91
1 files changed, 62 insertions, 29 deletions
diff --git a/scripts/setup-email.sh b/scripts/setup-email.sh
index 9cb23294..5d461691 100755
--- a/scripts/setup-email.sh
+++ b/scripts/setup-email.sh
@@ -2,11 +2,11 @@
# Craig Jennings <c@cjennings.net>
# Typically run on a fresh installation on a new machine.
-# - Decrypts mail passwords from encrypted .gpg files to ~/.config/
+# - Installs or decrypts mail password files into ~/.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
-# - Performs initial email indexing for both of my email accounts
+# - Performs initial email indexing for all email accounts
set -euo pipefail
@@ -25,35 +25,67 @@ MSMTPRC="$HOME/.msmtprc"
MAILROOT="$HOME/.mail"
GMAILDIR="$MAILROOT/gmail"
CMAILDIR="$MAILROOT/cmail"
+DMAILDIR="$MAILROOT/dmail"
+
+install_encrypted_password() {
+ local filename="$1"
+ local source_file="$ENCRYPTED_PASSWORDS_DIR/$filename"
+ local dest_file="$PASSWORD_DEST_DIR/$filename"
+
+ if [[ -f "$dest_file" ]]; then
+ echo " ✓ $dest_file already exists, skipping"
+ return
+ fi
+
+ if [[ ! -f "$source_file" ]]; then
+ echo " ✗ missing $dest_file and $source_file"
+ exit 1
+ fi
+
+ echo " → installing $filename..."
+ cp "$source_file" "$dest_file"
+ chmod 600 "$dest_file"
+ echo " ✓ created $dest_file"
+}
+
+decrypt_password() {
+ local encrypted_filename="$1"
+ local dest_filename="$2"
+ local source_file="$ENCRYPTED_PASSWORDS_DIR/$encrypted_filename"
+ local dest_file="$PASSWORD_DEST_DIR/$dest_filename"
+
+ if [[ -f "$dest_file" ]]; then
+ echo " ✓ $dest_file already exists, skipping"
+ return
+ fi
+
+ if [[ ! -f "$source_file" ]]; then
+ echo " ✗ missing $dest_file and $source_file"
+ exit 1
+ fi
+
+ echo " → decrypting $encrypted_filename..."
+ if gpg -q -d "$source_file" > "$dest_file" 2>/dev/null; then
+ chmod 600 "$dest_file"
+ echo " ✓ created $dest_file"
+ else
+ echo " ✗ failed to decrypt $encrypted_filename"
+ rm -f "$dest_file"
+ exit 1
+ fi
+}
# Decrypt Mail Passwords
-# Loop through all .gpg files in assets/mail-passwords/
-# Skip if destination already exists, decrypt if missing
+# Skip if destination already exists, install or 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"
+if [[ ! -d "$ENCRYPTED_PASSWORDS_DIR" ]]; then
+ echo " ✗ encrypted passwords directory not found: $ENCRYPTED_PASSWORDS_DIR"
+ exit 1
fi
+mkdir -p "$PASSWORD_DEST_DIR"
+install_encrypted_password ".gmailpass.gpg"
+decrypt_password ".cmailpass.gpg" ".cmailpass"
+install_encrypted_password ".dmailpass.gpg"
# Check All Prerequisites
[[ -x "$MBSYNC" ]] || { echo "ERROR: mbsync not found. Install 'isync'."; exit 1; }
@@ -64,7 +96,7 @@ fi
[[ -f "$MSMTPRC" ]] || { echo "ERROR: '~/.msmtprc' missing."; exit 1; }
# Ensure Mail Dirs Exist
-mkdir -p "$GMAILDIR" "$CMAILDIR"
+mkdir -p "$GMAILDIR" "$CMAILDIR" "$DMAILDIR"
# Initial Sync
echo "→ syncing all mail with mbsync ..."
@@ -74,7 +106,8 @@ echo "→ syncing all mail with mbsync ..."
echo "→ initializing mu ..."
"$MU" init --maildir="$MAILROOT" \
--my-address="craigmartinjennings@gmail.com" \
- --my-address="c@cjennings.net"
+ --my-address="c@cjennings.net" \
+ --my-address="craig.jennings@deepsat.com"
echo "→ indexing mail ..."
"$MU" index