printf "\`pass\` must be installed and initialized to encrypt passwords.\\nBe sure it is installed and run \`pass init <yourgpgemail>\`.\\nIf you don't have a GPG public private key pair, run \`$GPG --full-gen-key\` first.\\n"
printf "\`pass\` must be installed and initialized to encrypt passwords.\\nBe sure it is installed and run \`pass init <yourgpgemail>\`.\\nIf you don't have a GPG public private key pair, run \`$GPG --full-gen-key\` first.\\n"
exit
}
! command -v "$prefix/bin/mbsync" >/dev/null && printf "\`mbsync\` must be installed to run mutt-wizard.\\n" && exit
! command -v "$prefix/bin/msmtp" >/dev/null && printf "\`msmtp\` must be installed.\\n" && exit
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" "/etc/ssl/cert.pem" "/usr/local/share/ca-certificates/"
for mwcrt 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" "/etc/ssl/cert.pem" "/usr/local/share/ca-certificates/"
do
[ -f "$x" ] && sslcert="$x" && break
[ -f "$mwcrt" ] && mwsslcert="$mwcrt" && break
done || { echo "CA Certificate not found. Please install one or link it to /etc/ssl/certs/ca-certificates.crt" && exit 1 ;}
getaccounts() {
accounts="$(find "$mwaccrcdir" -type f | grep -o "[0-9]-.*.muttrc" | sed "s/-/: /;s/\.muttrc//" | sort -n)"
_mwgetaccounts() {
mwaccounts="$(find "$mwaccmuttdir" -type f | grep -o "[1-9]-.*.muttrc" | sed "s/-/: /;s/\.muttrc//" | sort -n)"
printf "Creating profiles for \`%s\`..." "$mwaddr"
msmtp_header="defaults
mwmsmtpheader="defaults
auth on
tls on
tls_trust_file $sslcert
tls_trust_file $mwsslcert
logfile ${XDG_LOG_HOME:-$HOME}/msmtp.log
"
msmtp_profile="account $mwacc
mwmsmtpprofile="account $mwacc
host $mwsmtp
port $mwsport
from $mwaddr
user $mwlogin
passwordeval \"pass $mwpass\"
$starttlsoff
$mwstarttlsoff
"
mbsync_profile="IMAPStore $mwacc-remote
mwmbsyncprofile="IMAPStore $mwacc-remote
Host $mwimap
Port $mwiport
User $mwlogin
PassCmd \"pass $mwpass\"
SSLType $mwssltype
CertificateFile $sslcert
CertificateFile $mwsslcert
MaildirStore $mwacc-local
Subfolders Verbatim
@@ -112,7 +111,7 @@ MaxMessages 0
"
if [ "$mwtype" = "offline" ]; then
mutt_profile="# vim: filetype=neomuttrc
mwmuttprofile="# vim: filetype=neomuttrc
# muttrc file for account $mwaddr
set realname = \"$mwname\"
set from = \"$mwaddr\"
@@ -126,7 +125,7 @@ macro index gm \"<shell-escape>mailsync $mwacc<enter>\" \"sync mail $mwaddr\"
unmailboxes *
"
else
mutt_profile="# vim: filetype=neomuttrc
mwmuttprofile="# vim: filetype=neomuttrc
# muttrc file for account $mwaddr
set realname = \"$mwname\"
set from = \"$mwaddr\"
@@ -149,16 +148,16 @@ fi
printf "DONE.\\n"
}
askinfo() {
_mwaskinfo() {
if [ -z "$mwaddr" ]; then
printf "Type the \033[31memail address\033[0m\\n\t\033[36m"
read -r mwaddr
printf "\033[0m"
while ! echo "$mwaddr" | grep "$mwemailre" >/dev/null; do
printf "That is not a valid \033[31memail address\033[0m, please retype\\n\t\033[36m"
read -r mwaddr
printf "\033[0m"
done
printf "Type the \033[31memail address\033[0m\\n\t\033[36m"
read -r mwaddr
printf "\033[0m"
while ! echo "$mwaddr" | grep "$mwemailre" >/dev/null; do
printf "That is not a valid \033[31memail address\033[0m, please retype\\n\t\033[36m"
read -r mwaddr
printf "\033[0m"
done
fi
mwdomain="$(echo "$mwaddr" | sed "s/.*@//")"
printf "\\nSearching for \033[32m%s\033[0m in \033[34m\`domains.csv\`\033[0m..." "$mwdomain"
@@ -183,74 +182,92 @@ EOF
gmail.com) printf "\033[31mGmail: \"less secure\" must be enabled before you continue.\\nDo it now, if you have not done it already:\\nhttps://support.google.com/accounts/answer/6010255\\n\033[0m" ;;
protonmail.ch|protonmail.com|pm.me) printf "\033[31mProtonmail: Users must install and configure Protonmail Bridge for the sync to work:\\nhttps://protonmail.com/bridge/\\n\033[0m" && ssltype="None" ;;
printf "Type your account username if different from your email address.\\n\033[34mFor most accounts you can probably leave this blank.\033[0m\\n\tLogin(?): \033[36m"
read -r mwlogin
printf "\033[0m"
[ -z "$mwlogin" ] && mwlogin="$mwaddr"
printf "Type your account username if different from your email address.\\n\033[34mFor most accounts you can probably leave this blank.\033[0m\\n\tLogin(?): \033[36m"
read -r mwlogin
printf "\033[0m"
[ -z "$mwlogin" ] && mwlogin="$mwaddr"
fi
# if the user has a pass entry he could provide it via mwpass
printf "\033[31m\033[31mLog-on not successful.\033[0m\\nIt seems that either you inputted the wrong password or server settings, or there are other requirements for your account out of the control of mutt-wizard.\\n"
@@ -258,125 +275,128 @@ tryconnect() {
fi
}
finalize() {
sed -i "/# mw-autogenerated/d" "$mwaccrc"
sed -i "/^mailboxes\|^set record\|^set postponed\|^set trash\|^set spoolfile/d" "$mwaccrc"
mwboxes="$(find "$mwaccmaildir/" -name cur | sed "s,$mwaccmaildir/,,g;s,/cur,,")"
if [[ "$mwboxes" =~ ^[[:space:]]*$ ]]; then
printf "\033[31mNo local mailboxes have been detected for %s.\033[0m\\nThis means that mbsync has not been successfully run.\\nRun mbsync, and if it has an error, be sure to check your password and server settings manually if needbe.\\n" "$mwacc"
return
fi
printf "Setting default mailboxes for your Inbox, Sent, Drafts and Trash in mutt...\\n"