You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mutt_install.sh 2.4 KiB

6 years ago
6 years ago
6 years ago
6 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/bin/bash
  2. muttdir="$HOME/.config/mutt/"
  3. mkdir -p ~/.config/mutt/credentials
  4. # Email for GPG
  5. youremail=$(\
  6. dialog --title "Luke's mutt/offlineIMAP password wizard" --inputbox "Insert the email address with which you originally created your key pair. This is NOT necessarily the email you want to configure." 10 60 \
  7. 3>&1 1>&2 2>&3 3>&- \
  8. )
  9. # Get email address
  10. fulladdr=$(\
  11. dialog --title "Luke's mutt/offlineIMAP autoconfig" --inputbox "Insert your full email address." 10 60 \
  12. 3>&1 1>&2 2>&3 3>&- \
  13. )
  14. # Check to see if domain is in domain list
  15. serverinfo=$(cat autoconf/domains.csv | grep -w ^${fulladdr##*@})
  16. if [ -z "$serverinfo" ]; then echo No suitable match. && exit; fi
  17. # Read in server data as variables
  18. IFS=, read service imap iport smtp sport spoolfile postponed record <<EOF
  19. $serverinfo
  20. EOF
  21. clear
  22. realname=$(\
  23. dialog --title "Luke's mutt/offlineIMAP autoconfig" --inputbox "Enter the full name you'd like to be identified by on this email account." 10 60 \
  24. 3>&1 1>&2 2>&3 3>&- \
  25. )
  26. title=$(\
  27. dialog --title "Luke's mutt/offlineIMAP autoconfig" --inputbox "Give a short, one-word name for this email account that will differentiate it from other email accounts." 10 60 \
  28. 3>&1 1>&2 2>&3 3>&- \
  29. )
  30. # Sets the repo type and other variables for the sed regex.
  31. if [[ "$service" == "gmail.com" ]];
  32. then
  33. type="Gmail"
  34. delet="remotehost"
  35. else
  36. type="IMAP"
  37. delet="Gmail]\/"
  38. fi
  39. # The replacements
  40. replacement="
  41. s/\$realname/$realname/g;
  42. s/\$title/$title/g;
  43. s/\$fulladdr/$fulladdr/g;
  44. s/\$imap/$imap/g;
  45. s/\$iport/$iport/g;
  46. s/\$smtp/$smtp/g;
  47. s/\$sport/$sport/g;
  48. s/\$spoolfile/$spoolfile/g;
  49. s/\$postponed/$postponed/g;
  50. s/\$record/$record/g;
  51. s/\$type/$type/g;
  52. /$delet/d"
  53. addAccount() {
  54. if [ ! -f ~/.offlineimaprc ]; then cp "$muttdir"autoconf/offlineimap_header ~/.offlineimaprc; fi
  55. cat "$muttdir"autoconf/offlineimap_profile | sed -e "$replacement" >> ~/.offlineimaprc
  56. # Add the mutt profile.
  57. cat "$muttdir"autoconf/mutt_profile | sed -e "$replacement" > "$muttdir"accounts/$title.muttrc
  58. # Add on offlineimaprc sync list.
  59. sed -i "s/^accounts =.*[a-zA-Z]$/&, $title/g;s/^accounts =$/accounts = $title/g" ~/.offlineimaprc ;}
  60. addAccount
  61. dialog --title "Luke's mutt/offlineIMAP password wizard" --passwordbox "Enter the password for the \"$title\" account." 10 60 2> /tmp/$title
  62. gpg -r $youremail --encrypt /tmp/$title
  63. shred -u /tmp/$title && echo "Password encrypted and memory shredded."
  64. mv /tmp/$title.gpg ~/.config/mutt/credentials/
  65. echo Done lmao.
  66. exit