|
@@ -125,22 +125,18 @@ fi |
|
|
printf "DONE.\\n" |
|
|
printf "DONE.\\n" |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
parsedomains(){ \ |
|
|
|
|
|
# Parses the domains.csv file for server information and sets |
|
|
|
|
|
# the required variables unless overridden by the user. |
|
|
|
|
|
serverinfo="$(grep "^${fulladdr#*@}" "$muttshare/domains.csv" 2>/dev/null)" |
|
|
|
|
|
|
|
|
parsedomains(){ serverinfo="$(grep "^${fulladdr#*@}" "$muttshare/domains.csv" 2>/dev/null)" |
|
|
|
|
|
|
|
|
[ -z "$serverinfo" ] && |
|
|
|
|
|
serverinfo="$(grep "$(echo "${fulladdr#*@}" | sed "s/\.[^\.]*$/\.\\\*/")" "$muttshare/domains.csv" 2>/dev/null)" |
|
|
|
|
|
|
|
|
[ -z "$serverinfo" ] && serverinfo="$(grep "$(echo "${fulladdr#*@}" | sed "s/\.[^\.]*$/\.\\\*/")" "$muttshare/domains.csv" 2>/dev/null)" |
|
|
|
|
|
|
|
|
IFS=, read -r service imapsugg iportsugg smtpsugg sportsugg <<EOF |
|
|
|
|
|
|
|
|
IFS=, read -r service imapsugg iportsugg smtpsugg sportsugg <<EOF |
|
|
$serverinfo |
|
|
$serverinfo |
|
|
EOF |
|
|
EOF |
|
|
imap="${imap:-$imapsugg}" |
|
|
|
|
|
smtp="${smtp:-$smtpsugg}" |
|
|
|
|
|
sport="${sport:-$sportsugg}" |
|
|
|
|
|
iport="${iport:-$iportsugg}" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
imap="${imap:-$imapsugg}" |
|
|
|
|
|
smtp="${smtp:-$smtpsugg}" |
|
|
|
|
|
sport="${sport:-$sportsugg}" |
|
|
|
|
|
iport="${iport:-$iportsugg}" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
delete() { if [ -z "${fulladdr+x}" ]; then |
|
|
delete() { if [ -z "${fulladdr+x}" ]; then |
|
|
echo "Select the account your would like to delete (by number):" |
|
|
echo "Select the account your would like to delete (by number):" |
|
@@ -160,7 +156,7 @@ delete() { if [ -z "${fulladdr+x}" ]; then |
|
|
rm -rf "${cachedir:?}/${fulladdr:?}" "$accdir/"[1-9]"-$fulladdr.muttrc" |
|
|
rm -rf "${cachedir:?}/${fulladdr:?}" "$accdir/"[1-9]"-$fulladdr.muttrc" |
|
|
sed -ibu "/[0-9]-$fulladdr.muttrc/d" "$muttrc" ; rm -f "$muttrc"bu |
|
|
sed -ibu "/[0-9]-$fulladdr.muttrc/d" "$muttrc" ; rm -f "$muttrc"bu |
|
|
sed -ibu "/account $fulladdr/,/^\(\s*$\|account\)/d" "$msmtprc"; rm -f "$msmtprc"bu |
|
|
sed -ibu "/account $fulladdr/,/^\(\s*$\|account\)/d" "$msmtprc"; rm -f "$msmtprc"bu |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
askinfo() { \ |
|
|
askinfo() { \ |
|
|
[ -z "$fulladdr" ] && echo "Give the full email address to add:" && |
|
|
[ -z "$fulladdr" ] && echo "Give the full email address to add:" && |
|
@@ -185,8 +181,7 @@ askinfo() { \ |
|
|
writeinfo() { mkdir -p "$muttdir" "$accdir" "$cachedir/$fulladdr/bodies" "${XDG_CONFIG_HOME:-$HOME/.config}/msmtp" "$maildir/$fulladdr" |
|
|
writeinfo() { mkdir -p "$muttdir" "$accdir" "$cachedir/$fulladdr/bodies" "${XDG_CONFIG_HOME:-$HOME/.config}/msmtp" "$maildir/$fulladdr" |
|
|
|
|
|
|
|
|
# Get accounts and find the first missing account number (max. 9). |
|
|
# Get accounts and find the first missing account number (max. 9). |
|
|
getaccounts |
|
|
|
|
|
for x in $(seq 1 9); do echo "$accounts" | grep -q "$x" || { export idnum="$x"; break ;}; done |
|
|
|
|
|
|
|
|
getaccounts; for x in $(seq 1 9); do echo "$accounts" | grep -q "$x" || { export idnum="$x"; break ;}; done |
|
|
|
|
|
|
|
|
# Configure msmtprc for sending mail. |
|
|
# Configure msmtprc for sending mail. |
|
|
[ ! -f "$msmtprc" ] && echo "$msmtp_header" > "$msmtprc" |
|
|
[ ! -f "$msmtprc" ] && echo "$msmtp_header" > "$msmtprc" |
|
@@ -205,8 +200,7 @@ writeinfo() { mkdir -p "$muttdir" "$accdir" "$cachedir/$fulladdr/bodies" "${XDG_ |
|
|
! grep "^source.*.muttrc" "$muttrc" | grep -qv "$mwconfig" && echo "source $accdir/$idnum-$fulladdr.muttrc $MARKER" >> "$muttrc" |
|
|
! grep "^source.*.muttrc" "$muttrc" | grep -qv "$mwconfig" && echo "source $accdir/$idnum-$fulladdr.muttrc $MARKER" >> "$muttrc" |
|
|
echo "macro index,pager i$idnum '<sync-mailbox><enter-command>source $accdir/$idnum-$fulladdr.muttrc<enter><change-folder>!<enter>;<check-stats>' \"switch to $fulladdr\" $MARKER" >> "$muttrc" |
|
|
echo "macro index,pager i$idnum '<sync-mailbox><enter-command>source $accdir/$idnum-$fulladdr.muttrc<enter><change-folder>!<enter>;<check-stats>' \"switch to $fulladdr\" $MARKER" >> "$muttrc" |
|
|
|
|
|
|
|
|
# Create a notmuch config file if not present already. |
|
|
|
|
|
notmuchauto |
|
|
|
|
|
|
|
|
notmuchauto # Create a notmuch config file if not present already. |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protonfinger() { printf "Getting Protonmail bridge fingerprint...\\n" |
|
|
protonfinger() { printf "Getting Protonmail bridge fingerprint...\\n" |
|
@@ -283,9 +277,7 @@ synchronize_flags=true |
|
|
gpg_path=$GPG" |
|
|
gpg_path=$GPG" |
|
|
echo "$nmbasic" > "$NOTMUCH_CONFIG" ;} |
|
|
echo "$nmbasic" > "$NOTMUCH_CONFIG" ;} |
|
|
|
|
|
|
|
|
trap 'echo -e "\033[0m\n"; exit' INT ABRT |
|
|
|
|
|
|
|
|
|
|
|
setaction() { if [ -n "${action+x}" ] && [ "$action" != "$1" ]; then |
|
|
|
|
|
|
|
|
setact() { if [ -n "${action+x}" ] && [ "$action" != "$1" ]; then |
|
|
echo "Running $1 with $action..." |
|
|
echo "Running $1 with $action..." |
|
|
echo "Incompatible options given. Only one action may be specified per run." |
|
|
echo "Incompatible options given. Only one action may be specified per run." |
|
|
return 1 |
|
|
return 1 |
|
@@ -293,22 +285,24 @@ setaction() { if [ -n "${action+x}" ] && [ "$action" != "$1" ]; then |
|
|
action="$1" |
|
|
action="$1" |
|
|
fi; } |
|
|
fi; } |
|
|
|
|
|
|
|
|
|
|
|
trap 'echo -e "\033[0m\n"; exit' INT ABRT |
|
|
|
|
|
|
|
|
while getopts "fplhdYD:y:i:I:s:S:u:a:n:" o; do case "${o}" in |
|
|
while getopts "fplhdYD:y:i:I:s:S:u:a:n:" o; do case "${o}" in |
|
|
l) setaction list || exit 1 ;; |
|
|
|
|
|
d) setaction delete || exit 1 ;; |
|
|
|
|
|
D) setaction delete || exit 1 ; fulladdr="$OPTARG" ;; |
|
|
|
|
|
y) setaction sync || exit 1 ; fulladdr="$OPTARG" ;; |
|
|
|
|
|
Y) setaction sync || exit 1 ;; |
|
|
|
|
|
a) setaction add || exit 1 ; fulladdr="$OPTARG" ;; |
|
|
|
|
|
i) setaction add || exit 1 ; imap="$OPTARG" ;; |
|
|
|
|
|
I) setaction add || exit 1 ; iport="$OPTARG" ;; |
|
|
|
|
|
s) setaction add || exit 1 ; smtp="$OPTARG" ;; |
|
|
|
|
|
S) setaction add || exit 1 ; sport="$OPTARG" ;; |
|
|
|
|
|
u) setaction add || exit 1 ; login="$OPTARG" ;; |
|
|
|
|
|
n) setaction add || exit 1 ; realname="$OPTARG" ;; |
|
|
|
|
|
m) setaction add || exit 1 ; maxmes="$OPTARG" ;; |
|
|
|
|
|
o) setaction add || exit 1 ; online=True ;; |
|
|
|
|
|
f) setaction add || exit 1 ; force=True ;; |
|
|
|
|
|
|
|
|
l) setact list || exit 1 ;; |
|
|
|
|
|
d) setact delete || exit 1 ;; |
|
|
|
|
|
D) setact delete || exit 1 ; fulladdr="$OPTARG" ;; |
|
|
|
|
|
y) setact sync || exit 1 ; fulladdr="$OPTARG" ;; |
|
|
|
|
|
Y) setact sync || exit 1 ;; |
|
|
|
|
|
a) setact add || exit 1 ; fulladdr="$OPTARG" ;; |
|
|
|
|
|
i) setact add || exit 1 ; imap="$OPTARG" ;; |
|
|
|
|
|
I) setact add || exit 1 ; iport="$OPTARG" ;; |
|
|
|
|
|
s) setact add || exit 1 ; smtp="$OPTARG" ;; |
|
|
|
|
|
S) setact add || exit 1 ; sport="$OPTARG" ;; |
|
|
|
|
|
u) setact add || exit 1 ; login="$OPTARG" ;; |
|
|
|
|
|
n) setact add || exit 1 ; realname="$OPTARG" ;; |
|
|
|
|
|
m) setact add || exit 1 ; maxmes="$OPTARG" ;; |
|
|
|
|
|
o) setact add || exit 1 ; online=True ;; |
|
|
|
|
|
f) setact add || exit 1 ; force=True ;; |
|
|
p) echo "NOTE: Protonmail users must install and configure Protonmail Bridge first for the first sync to work." |
|
|
p) echo "NOTE: Protonmail users must install and configure Protonmail Bridge first for the first sync to work." |
|
|
proton=True |
|
|
proton=True |
|
|
imap="127.0.0.1" |
|
|
imap="127.0.0.1" |
|
@@ -317,7 +311,7 @@ while getopts "fplhdYD:y:i:I:s:S:u:a:n:" o; do case "${o}" in |
|
|
sport="1025" |
|
|
sport="1025" |
|
|
ssltype="None" |
|
|
ssltype="None" |
|
|
protonfinger |
|
|
protonfinger |
|
|
setaction add || exit 1 |
|
|
|
|
|
|
|
|
setact add || exit 1 |
|
|
;; |
|
|
;; |
|
|
*) cat << EOF |
|
|
*) cat << EOF |
|
|
mw: mutt-wizard, auto-configure email accounts for mutt |
|
|
mw: mutt-wizard, auto-configure email accounts for mutt |
|
|