summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorLuke Smith <luke@lukesmith.xyz>2021-01-06 21:13:48 -0500
committerLuke Smith <luke@lukesmith.xyz>2021-01-06 21:13:48 -0500
commitca9f1a12ccbc01889fd2a1257462594e4d2ea272 (patch)
tree0ae0461396bf9a1787be2fcb733db9ba17e61dc7 /bin
parent4dbf70e40355b73b16a3b0b010960a0d1a681740 (diff)
use curl to login
rm mbsync requirement for online storage
Diffstat (limited to 'bin')
-rwxr-xr-xbin/mw17
1 files changed, 6 insertions, 11 deletions
diff --git a/bin/mw b/bin/mw
index 3586df7..f009e90 100755
--- a/bin/mw
+++ b/bin/mw
@@ -199,9 +199,8 @@ writeinfo() { mkdir -p "$muttdir" "$accdir" "$cachedir/$fulladdr/bodies" "${XDG_
# On Ubuntu/Debian, a link is needed since they use an older version.
command -V apt-get >/dev/null 2>&1 && ln -s "$msmtprc" "$HOME/.msmtprc" 2>/dev/null
- # Create the mbsync config file.
- mkdir -p "${mbsyncrc%/*}"
- echo "$mbsync_profile" >> "$mbsyncrc"
+ # Create the mbsync config file if local account.
+ [ -z "${online+x}" ] && mkdir -p "${mbsyncrc%/*}" && echo "$mbsync_profile" >> "$mbsyncrc"
# Create a muttrc for viewing mail.
echo "$mutt_profile" > "$accdir/$idnum-$fulladdr.muttrc"
@@ -230,14 +229,10 @@ Junk
Trash
Sent
Archive" && return 0
- if mailboxes="$(mbsync -l "$fulladdr" | sed 's/\//./')" >/dev/null 2>&1 && [ -n "$mailboxes" ]; then
- [ -n "${online+x}" ] && sed -ibu "/IMAPStore $fulladdr-remote$/,/# End profile/d" "$mbsyncrc" ; rm -f "$mbsyncrc"bu
- return 0
- else
- echo "$mailboxes"
- echo "Log-on not successful."
- return 1
- fi ;}
+ info="$(curl -s --user "$login:$(pass $pass_prefix$fulladdr)" --url "${protocol:-imaps}://$imap")" ||
+ { echo "Log-on not successful." ; exit 1 ;}
+ mailboxes="$(echo "$info" | sed "s/.*\" //" | tr -d ' ')"
+}
finalize() { echo "$mailboxes" | xargs -I {} mkdir -p "$maildir/$fulladdr/{}/cur" "$maildir/$fulladdr/{}/tmp" "$maildir/$fulladdr/{}/new"
sed -ibu "/$marker/d" "$accdir/$idnum-$fulladdr.muttrc" ; rm -f "$accdir/$idnum-$fulladdr.muttrcbu"