diff options
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/build-emacs-from-source.sh | 21 | ||||
| -rwxr-xr-x | scripts/setup-email.sh | 86 |
2 files changed, 59 insertions, 48 deletions
diff --git a/scripts/build-emacs-from-source.sh b/scripts/build-emacs-from-source.sh index a2272838..e28d19a5 100755 --- a/scripts/build-emacs-from-source.sh +++ b/scripts/build-emacs-from-source.sh @@ -16,18 +16,33 @@ # ...and I'm avoiding native compilation at the moment #./configure --with-native-compilation \ -set -e +# debugging assistance +set -euo pipefail +# -e: exit on any (non-zero) return‐code +# -u: treat unset variables as errors +# -o pipefail: if any stage of a pipeline fails, the whole pipeline fails + +# optional: show each command as you go, prefixed with file:line +# export PS4='+ ${BASH_SOURCE[0]}:${LINENO}: ' +# set -x + +# trap all errors and identify line +trap 'echo "❌ ERROR at ${BASH_SOURCE[0]}:${LINENO}: $BASH_COMMAND" >&2' ERR # Review These Variables src_dir="$HOME/code/emacs" emacs_repo="https://github.com/mirrors/emacs.git" -emacs_tag="emacs-29.1" +emacs_tag="emacs-30.2" logfile="$HOME/emacs_build.log" # Function to remove + recreate directory, and clone source nuke_and_clone () { cd "$HOME" + if [ -f "$logfile" ]l then + rm "$logfile" + fi + if [ -d "$src_dir" ]; then printf "...removing directory %s\n\n" "$src_dir" rm -rf "$src_dir" >> "$logfile" 2>&1 @@ -71,7 +86,7 @@ else nuke_and_clone fi -if [ ! $1 == "latest" ]; then +if [ ! "${$1:-}" == "latest" ]; then printf "...checking out tag: %s\n" "$emacs_tag" | tee -a "$logfile" git checkout "$emacs_tag" >> "$logfile" 3>&1 else diff --git a/scripts/setup-email.sh b/scripts/setup-email.sh index 964e4226..7607eb61 100755 --- a/scripts/setup-email.sh +++ b/scripts/setup-email.sh @@ -1,51 +1,47 @@ #!/usr/bin/env bash -# ------------------------------ Notes ------------------------------ # Craig Jennings <c@cjennings.net> -# -# this mu4e mail setup script is particular to my own setup -# ===== this will not work for you without adjustments ===== -MBSYNC=/usr/bin/mbsync -MBSYNCRC="$HOME/.mbsyncrc" -MU4E_DIR=/usr/share/emacs/site-lisp/mu4e/ -MSMTP=/usr/bin/msmtp -MSMTPRC="$HOME/.msmtprc" -MU=/usr/bin/mu -GMAIL="$HOME/.mail/gmail" -CMAIL="$HOME/.mail/cmail" - -# ----------------------- Preliminary Checks ---------------------- -# is mbsync installed? -if ! [ -f $MBSYNC ]; then echo "mbsync not installed at $MBSYNC. Install package 'isync' to continue"; exit 1; fi -if ! [ -f $MU ]; then echo "mu not installed at $MU. Install package 'mu' to continue"; exit 1; fi -if ! [ -d $MU4E ]; then echo "mu4e elisp files not at $MU4E_DIR. Did you install the 'mu' package?"; exit 1; fi - -# does .mbsyncrc exist? -if ! [ -f $MBSYNCRC ]; then echo "necessary file .mbsyncrc not at $MBSYNCRC"; exit 1; fi - -# is msmtp installed? -if ! [ -f $MSMTP ]; then echo "msmtp not installed at $MSMTP. Install package 'msmtp and msmtp-mta' to continue"; exit 1; fi - -# does .msmtprc exist -if ! [ -f $MSMPTRC ]; then echo "necessary file .msmtprc not at $MBSYNCRC"; exit 1; fi +# Typically run on a fresh installation on a new machine. +# - 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 -# if mail directories don't exist, create them -if ! [ -f $GMAIL ]; then echo "creating gmail directory" && mkdir -p $GMAIL; fi -if ! [ -f $CMAIL ]; then echo "creating cmail directory" && mkdir -p $CMAIL; fi +set -euo pipefail -# -------------------------- Initial Sync ------------------------- +MBSYNC="$(command -v mbsync || true)" +MU="$(command -v mu || true)" +MU4EDIR="/usr/share/emacs/site-lisp/mu4e" +MSMTP="$(command -v msmtp || true)" -# sync -echo "syncing email... Note: You will be asked for your password" -$MBSYNC -aV - -# init -echo "running mu init..." -$MU init --maildir="$HOME/.mail" --my-address=craigmartinjennings@gmail.com --my-address=c@cjennings.net - -# index -echo "running mu index..." -$MU index - -# report completion -echo "" && echo "Mu4e mail setup script completed." && echo "" && echo "" +MBSYNCRC="$HOME/.mbsyncrc" +MSMTPRC="$HOME/.msmtprc" +MAILROOT="$HOME/.mail" +GMAILDIR="$MAILROOT/gmail" +CMAILDIR="$MAILROOT/cmail" + +# 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; } +[[ -d "$MU4EDIR" ]] || { echo "ERROR: mu4e elisp not found at $MU4EDIR. Install 'mu'."; exit 1; } +[[ -f "$MBSYNCRC" ]] || { echo "ERROR: '~/.mbsyncrc' missing."; exit 1; } +[[ -x "$MSMTP" ]] || { echo "ERROR: msmtp not found. Install 'msmtp'."; exit 1; } +[[ -f "$MSMTPRC" ]] || { echo "ERROR: '~/.msmtprc' missing."; exit 1; } + +# Ensure Mail Dirs Exist +mkdir -p "$GMAILDIR" "$CMAILDIR" + +# Initial Sync +echo "→ syncing all mail with mbsync ..." +"$MBSYNC" -aV + +# Init MU and Index Email +echo "→ initializing mu ..." +"$MU" init --maildir="$MAILROOT" \ + --my-address="craigmartinjennings@gmail.com" \ + --my-address="c@cjennings.net" + +echo "→ indexing mail ..." +"$MU" index + +echo "✅ Mail setup complete." |
