mirror of
https://github.com/correl/dotfiles.git
synced 2024-11-30 19:19:53 +00:00
144 lines
3.6 KiB
Bash
144 lines
3.6 KiB
Bash
#!/bin/bash
|
|
# Description: Email syncing tools plus the mu4e client
|
|
set -e
|
|
|
|
__MAXMESSAGES=100
|
|
|
|
function __certificatefile {
|
|
for path in \
|
|
/usr/local/etc/ssl \
|
|
/usr/local/etc/openssl \
|
|
/usr/local/etc/openssl@1.1 \
|
|
/etc/ssl \
|
|
/etc/openssl \
|
|
; do
|
|
|
|
for certfile in \
|
|
cert.pem \
|
|
certs/ca-certificates.crt \
|
|
; do
|
|
|
|
if test -f "${path}/${certfile}"; then
|
|
echo "${path}/${certfile}"
|
|
return
|
|
fi
|
|
done
|
|
done
|
|
}
|
|
|
|
function __mbsync_config {
|
|
cat > ${HOME}/.mbsyncrc <<EOF
|
|
IMAPAccount personal
|
|
Host imap.gmail.com
|
|
User correl@gmail.com
|
|
PassCmd "pass accounts.google.com/correl@gmail.com | grep ^isync: | awk '{print \$2}'"
|
|
AuthMechs LOGIN
|
|
SSLType IMAPS
|
|
SSLVersions TLSv1.2
|
|
CertificateFile $(__certificatefile)
|
|
|
|
IMAPStore personal-remote
|
|
Account personal
|
|
|
|
MaildirStore personal-local
|
|
Subfolders Verbatim
|
|
Path ~/Mail/Personal/
|
|
Inbox ~/Mail/Personal/INBOX
|
|
|
|
Channel personal
|
|
Far :personal-remote:
|
|
Near :personal-local:
|
|
MaxMessages ${__MAXMESSAGES}
|
|
ExpireUnread yes
|
|
Patterns "INBOX" "[Gmail]/Drafts" "[Gmail]/Sent Mail" "[Gmail]/Starred" "[Gmail]/All Mail" "[Gmail]/Chats" "[Gmail]/Trash"
|
|
Create Both
|
|
Expunge Both
|
|
SyncState *
|
|
|
|
IMAPAccount work
|
|
Host imap.gmail.com
|
|
User correlr@aweber.com
|
|
PassCmd "pass Work/aweber/accounts.google.com/correlr@aweber.com | grep ^isync: | awk '{print \$2}'"
|
|
AuthMechs LOGIN
|
|
SSLType IMAPS
|
|
SSLVersions TLSv1.2
|
|
CertificateFile $(__certificatefile)
|
|
|
|
IMAPStore work-remote
|
|
Account work
|
|
|
|
MaildirStore work-local
|
|
Subfolders Verbatim
|
|
Path ~/Mail/Work/
|
|
Inbox ~/Mail/Work/INBOX
|
|
|
|
Channel work
|
|
Far :work-remote:
|
|
Near :work-local:
|
|
MaxMessages ${__MAXMESSAGES}
|
|
ExpireUnread yes
|
|
Patterns "INBOX" "AWeber Times" "Jira" "[Gmail]/Drafts" "[Gmail]/Sent Mail" "[Gmail]/Starred" "[Gmail]/All Mail" "[Gmail]/Chats" "[Gmail]/Trash"
|
|
Create Both
|
|
Expunge Both
|
|
SyncState *
|
|
EOF
|
|
}
|
|
|
|
_recipe emacs
|
|
case $_PLATFORM in
|
|
darwin)
|
|
_recipe brew
|
|
_brew isync
|
|
EMACS=$(which emacs) _brew mu --HEAD
|
|
;;
|
|
arch)
|
|
_recipe _arch
|
|
_pacman isync
|
|
_yay mu
|
|
;;
|
|
debian)
|
|
_recipe _apt
|
|
for dep in \
|
|
build-essential \
|
|
autoconf \
|
|
automake \
|
|
libtool \
|
|
texinfo \
|
|
libgmime-3.0-dev \
|
|
libxapian-dev \
|
|
guile-2.0-dev \
|
|
html2text \
|
|
xdg-utils \
|
|
libwebkitgtk-dev \
|
|
isync
|
|
do
|
|
_apt $dep
|
|
done
|
|
dir=`mktemp -d` && \
|
|
pushd $dir >/dev/null
|
|
if ! command -v mu >/dev/null; then
|
|
echo "[tgz] Fetching mu"
|
|
curl -sL https://github.com/djcb/mu/archive/master.tar.gz \
|
|
| tar xz --strip 1 && \
|
|
echo "[tgz] Configuring mu" && \
|
|
./autogen.sh >/dev/null 2>&1 && \
|
|
./configure --prefix=/usr >/dev/null 2>&1 && \
|
|
echo "[tgz] Building mu" && \
|
|
make >/dev/null 2>&1 && \
|
|
echo "[tgz] Installing mu" && \
|
|
sudo make install >/dev/null 2>&1
|
|
popd >/dev/null
|
|
rm -rf "$dir"
|
|
fi
|
|
;;
|
|
esac
|
|
|
|
_run "[email] Creating mail directories" mkdir -p ${HOME}/Mail/{Personal,Work,.attachments}
|
|
_run "[email] Configuring mbsync" __mbsync_config
|
|
_run "[email] Initializing mail database" mu init -m ${HOME}/Mail \
|
|
--my-address=correl@gmail.com \
|
|
--my-address=correlr@aweber.com \
|
|
--my-address=correlr@aweber.net
|
|
_run "[email] Indexing mail" mu index
|
|
_recipe nvm
|
|
_npm imapnotify
|