diff options
Diffstat (limited to 'bin/mw')
-rwxr-xr-x | bin/mw | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -11,6 +11,7 @@ mbsyncrc="$HOME/.mbsyncrc" mwconfig="$muttshare/mutt-wizard.muttrc" cachedir="$HOME/.cache/mutt-wizard" muttrc="$muttdir/muttrc" +msmtprc="$HOME/.config/msmtp/config" ssltype="IMAPS" # This is later changed to `None` later in the script if using Protonmail for x in "/etc/ssl/certs/ca-certificates.crt" "/etc/pki/tls/certs/ca-bundle.crt" "/etc/ssl/ca-bundle.pem" "/etc/pki/tls/cacert.pem" "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem" @@ -140,7 +141,7 @@ EOF printf "\\n\033[3;33mCongrats!\033[0m Server info has automatically been found, so you won't have to look anything up!\\n\t\033[1mIMAP server\033[0m: %s\\n\t\033[1mIMAP port\033[0m: %s\\n\t\033[1mSMTP server\033[0m: %s\\n\t\033[1mSMTP port\033[0m: %s\\nThis data will be used by the wizard.\\n" "$imap" "$iport" "$smtp" "$sport" case "$service" in gmail.com) printf "\033[31mREMEMBER: Gmail users must enable \"less secure\" (third-party) applications first for the sync to work:\\nhttps://support.google.com/accounts/answer/6010255\\n\033[0m" ;; - protonmail.*) printf "\033[31mREMEMBER: Protonmail users must install and configure Protonmail Bridge first for the sync to work:\\nhttps://protonmail.com/bridge/\\n\033[0m" && ssltype="None" ;; + protonmail.ch|protonmail.com|pm.me) printf "\033[31mREMEMBER: Protonmail users must install and configure Protonmail Bridge first for the sync to work:\\nhttps://protonmail.com/bridge/\\n\033[0m" && ssltype="None" ;; esac fi printf "Enter the \033[35mfull name\033[0m you want to be identified by on this account.\\n\tReal name: " @@ -163,8 +164,11 @@ EOF mkdir -p "$muttdir" "$accdir" "$cachedir/$title/bodies" "$HOME/.config/msmtp" getaccounts for x in $(seq 1 9); do echo "$accounts" | grep "$x" >/dev/null 2>&1 || { export idnum="$x"; break ;}; done - [ ! -f "$HOME/.config/msmtp/config" ] && echo "$msmtp_header" > "$HOME/.config/msmtp/config" - echo "$msmtp_profile" >> "$HOME/.config/msmtp/config" + [ ! -f "$msmtprc" ] && echo "$msmtp_header" > "$msmtprc" + echo "$msmtp_profile" >> "$msmtprc" + case "$service" in + protonmail.ch|protonmail.com|pm.me) protonfinger || return 1 ;; + esac echo "$mutt_profile" > "$accdir/$idnum-$title.muttrc" echo "$mbsync_profile" >> "$mbsyncrc" notmuchauto @@ -174,6 +178,11 @@ EOF echo "macro index,pager i$idnum '<sync-mailbox><enter-command>source $accdir/$idnum-$title.muttrc<enter><change-folder>!<enter>;<check-stats>' \"switch to $fulladdr\" # mw-autogenerated" >> "$muttrc" } +protonfinger() { printf "Getting Protonmail bridge fingerprint...\\n" + fingerprint="$(msmtp --serverinfo --tls --tls-certcheck=off -a "$title")" || return 1 + sed -ibu "s/account $title/&\ntls_fingerprint $fingerprint/" "$msmtprc" ; rm -f "$msmtprc"bu +} + getpass() { while : ; do pass rm -f "mutt-wizard-$title" >/dev/null 2>&1 pass insert "mutt-wizard-$title" && break; done ;} @@ -233,10 +242,10 @@ pick() { printf "Select an accounts to %s:\\n" "$1" delete() { sed -ibu "/IMAPStore $title-remote$/,/# End profile/d" "$mbsyncrc" ; rm -rf "$mbsyncrc"bu rm -rf "${cachedir:?}/${title:?}" "$accdir/"[1-9]"-$title.muttrc" sed -ibu "/[0-9]-$title.muttrc/d" "$muttrc" ; rm -f "$muttrc"bu - sed -ibu "/account $title/,/^\(\s*$\|account\)/d" "$HOME/.config/msmtp/config"; rm -f "$HOME/.config/msmtp/configbu" + sed -ibu "/account $title/,/^\(\s*$\|account\)/d" "$msmtprc"; rm -f "$msmtprc"bu } -choosecron() { ! pgrep -x cron\|crond >/dev/null && echo "No cron manager running. Install/enable one and then select this option again." && return 1 +choosecron() { ! pgrep cron >/dev/null && echo "No cron manager running. Install/enable one and then select this option again." && return 1 if crontab -l | grep mailsync >/dev/null; then echo "Active mail sync cronjob detected. Do you want to remove it?" printf "\033[36m\t" |