summaryrefslogtreecommitdiff
path: root/mutt-wizard.sh
diff options
context:
space:
mode:
Diffstat (limited to 'mutt-wizard.sh')
-rwxr-xr-xmutt-wizard.sh42
1 files changed, 23 insertions, 19 deletions
diff --git a/mutt-wizard.sh b/mutt-wizard.sh
index 7256f16..1fd21a8 100755
--- a/mutt-wizard.sh
+++ b/mutt-wizard.sh
@@ -9,6 +9,12 @@ fi
muttdir="$HOME/.config/mutt/"
+createMailboxes() { rm -f "$muttdir"autoconf/log
+ offlineimap --info -a $1 2&> "$muttdir"autoconf/log
+ for box in $(sed -n '/^Folderlist/,/^Folderlist/p' "$muttdir"autoconf/log |
+ grep "^ " | awk '{print $1}' | sed -e 's/\//./g')
+ do mkdir -p $HOME/.mail/$1/$box; done ;}
+
chooseSync() { (crontab -l && testSync) || dialog --msgbox "No cronjob manager detected. Please install one and return to enable automatic mailsyncing" 10 60 ;}
testSync() { (crontab -l | grep .config/mutt/etc/mailsync && removeSync) || addSync ;}
@@ -113,7 +119,7 @@ removeAccount() { sed -ie "
rm "$muttdir"accounts/$1.muttrc
rm "$muttdir"credentials/$1.gpg
rm -rf "$muttdir"accounts/$1
- sed -i '/$1.muttrc/d' "$muttdir"personal.muttrc ;}
+ sed -i "/$1.muttrc/d" "$muttdir"personal.muttrc ;}
manual() { \
imap=$( dialog --inputbox "Insert the IMAP server for your email provider (excluding the port number)" 10 60 3>&1 1>&2 2>&3 3>&- )
@@ -196,12 +202,12 @@ addAccount() {
grep "$muttdir"personal.muttrc -e "^source .*accounts.*" >/dev/null && echo there || \
echo "source ${muttdir}accounts/$title.muttrc" >> "$muttdir"personal.muttrc
- dialog --title "Finalizing your account." --msgbox "The account \"$title\" has been added. Now to finalize installation, do the following:
-
- 1) Run offlineimap to start the sync. This will start your mail sync.
- 2) After or while running offlineimap, choose the \"autodetect mailboxes\" option, which will finalize your config files based on the directory structure of the downloaded mailbox.
+ dialog --title "Finalizing your account." --infobox "The account \"$title\" has been added. Now attempting to configure mail directories...
- After that, you will be able to open neomutt to your email account." 13 80 ;}
+ This may take several seconds..." 10 70
+ createMailboxes $title || (clear && exit)
+ detectMailboxes $title
+ dialog --title "Account added." --msgbox "Your "$fulladdr" account has been added. To start the download of your mail, you can manually run \`offlineimap -a $title\` in a terminal. The first sync may take some time depending on the amount of your mail." 8 60 ;}
# This is run when a user chooses to add an account.
chooseAdd() { \
@@ -222,15 +228,14 @@ wipe () { rm $HOME/.offlineimaprc
while : ;
do
choice=$(dialog --title "Luke's mutt/offlineIMAP wizard" --nocancel \
- --menu "What would you like to do?" 16 45 8 \
+ --menu "What would you like to do?" 14 45 7 \
0 "List all email accounts configured." \
1 "Add an email account." \
- 2 "Auto-detect mailboxes for an account." \
- 3 "Enable/disable autosync." \
- 4 "Change an account's password." \
- 5 "Remove an email account." \
- 6 "Remove all email accounts." \
- 7 "Exit this wizard." \
+ 2 "Enable/disable autosync." \
+ 3 "Change an account's password." \
+ 4 "Remove an email account." \
+ 5 "Remove all email accounts." \
+ 6 "Exit this wizard." \
3>&1 1>&2 2>&3 3>&1 )
case $choice in
@@ -238,11 +243,10 @@ case $choice in
$(grep ~/.offlineimaprc -e "^accounts =" | sed 's/accounts =//g')
" 6 60;;
1) chooseAdd;;
-2) detectWarning && chooseDetect ;;
-3) chooseSync;;
-4) inventory && for i in $userchoices; do changePassword $i ; done;;
-5) inventory && for i in $userchoices; do removeAccount $i ; done;;
-6) (dialog --defaultno --title "Wipe all custom neomutt/offlineIMAP settings?" --yesno "Would you like to wipe all of the mutt/offlineIMAP settings generated by the system?" 6 60 && wipe) ;;
-7) clear && break ;;
+2) chooseSync;;
+3) inventory && for i in $userchoices; do changePassword $i ; done;;
+4) inventory && for i in $userchoices; do removeAccount $i ; done;;
+5) (dialog --defaultno --title "Wipe all custom neomutt/offlineIMAP settings?" --yesno "Would you like to wipe all of the mutt/offlineIMAP settings generated by the system?" 6 60 && wipe) ;;
+6) clear && break ;;
esac
done