! ping -q -c 1 1.1.1.1 > /dev/null && printf "No internet connection detected.\\nTry rerunning \`mbsync $title\` manually when connection is established, then select the option to detect mailboxes and finalize installation.\\n" && return 1
! ping -q -c 1 1.1.1.1 > /dev/null && printf "No internet connection detected.\\nTry rerunning \`mbsync %s\` manually when connection is established, then select the option to detect mailboxes and finalize installation.\\n" "$title" && return 1
printf "\033[32mYou must have an internet connection to continue.\033[0m\\nmutt-wizard will run mbsync briefly to (1) ensure that login details are functional and (2) allow mbsync to tell us what mailboxes your email account has.\\nAfter around 15 seconds, mutt-wizard will kill the process and continue.\\nYou can run mbsync manually to finish the mail sync later.\\n"
printf "\033[32mYou must have an internet connection to continue.\033[0m\\nmutt-wizard will run mbsync briefly to (1) ensure that login details are functional and (2) allow mbsync to tell us what mailboxes your email account has.\\nAfter around 15 seconds, mutt-wizard will kill the process and continue.\\nYou can run mbsync manually to finish the mail sync later.\\n"
cont
cont
(sleep 15; killall mbsync)>/dev/null 2>&1 &
mkdir -p "$maildir/$title"
mkdir -p "$maildir/$title"
mbsync "$title"
if ls -d "$maildir/$title/"* >/dev/null 2>&1; then
printf "\033[31m\033[31mSync not successful.\033[0m Try running \`mbsync $title\` manually after double-checking your password and server settings.\\nThen select to finalize the account.\\n"; return 1
printf "\033[31m\033[31mSync not successful.\033[0m Try running \`mbsync %s\` manually after double-checking your password and server settings.\\nThen select to finalize the account.\\n" "$title"; return 1
fi
fi
}
}
@@ -278,15 +270,14 @@ finalize() { \
printf "All done.\\n"
printf "All done.\\n"
}
}
wipe () { \
printf "Are you \033[31;1mreally\033[0m sure you want to delete all email accounts?\\n" && read -r input && ! echo "$input" | grep -i "y\(es\)*" >/dev/null && printf "That doesn't seem like a yes to me.\\n\\n" && return 1
printf "Are you really, really sure?" && read -r input && ! echo "$input" | grep -i "y\(es\)*" >/dev/null && printf "That doesn't seem like a yes to me.\\n\\n" && return 1
rm -rf "$mbsyncrc" "$accdir" "$creddir" "$muttdir/personal.muttrc" && echo "All configs and account settings have been purged."
}
confirm() { printf "Are you \033[31;1mreally\033[0m sure you want to %s?\\n\t" "$@" && read -r input && ! echo "$input" | grep -i "y\(es\)*" >/dev/null && printf "That doesn't seem like a yes to me.\\n\\n" && return 1
printf "Are you really, really sure you want to %s?\\n\t" "$@" && read -r input && ! echo "$input" | grep -i "y\(es\)*" >/dev/null && printf "That doesn't seem like a yes to me.\\n\\n" && return 1
return 0 ;}
pick() { \
pick() { \
numbered="$(ls $accdir/*muttrc | sed "s/.*\///;s/\..*//" | nl)"
numbered="$(ls $accdir/*muttrc | sed "s/.*\///;s/\..*//" | nl)"
[ "$(echo "$numbered" | wc -w)" = 0 ] && printf "No accounts to delete.\\n" && return 1
[ "$(echo "$numbered" | wc -w)" = 0 ] && printf "No accounts to choose from.\\n" && return 1
! command -v mbsync >/dev/null && printf "You must have the \`mbsync\` command to add an account.\\nIt syncs mail and detects remote mailboxes.\\nYou can typically get it by installing \`isync\`.\\n" && return 1
while : ; do
while : ; do
echo "Do you want to keep your mail for this account offline with mbsync? [yes/no]"
echo "Do you want to keep your mail for this account offline with mbsync? [yes/no]"
read -r offnot
read -r offnot
@@ -368,7 +358,6 @@ What would you like \033[32mmutt-wizard\033[0m to do?
5 Change GPG key pair used for encryption
5 Change GPG key pair used for encryption
6 Delete all account data
6 Delete all account data
7 Enable/disable autosync
7 Enable/disable autosync
9 Edit this script
0 Exit
0 Exit
Input a number to continue or press ctrl-c.\\n"
Input a number to continue or press ctrl-c.\\n"
printf "\033[36m\t"
printf "\033[36m\t"
@@ -377,12 +366,11 @@ Input a number to continue or press ctrl-c.\\n"
case "$choice" in
case "$choice" in
1) addtype ;;
1) addtype ;;
2) pick finalize && finalize ;;
2) pick finalize && finalize ;;
3) pick "change the password of" yes && getpass ;;
4) pick delete yes && delete ;;
3) pick "change the password of" && confirm "change the password of" && getpass ;;