Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 

87 rindas
2.5 KiB

  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" ];
  17. then
  18. echo No suitable match. && exit
  19. else
  20. # Read in server data as variables
  21. IFS=, read service imap iport smtp sport spoolfile postponed record <<EOF
  22. $serverinfo
  23. EOF
  24. fi
  25. realname=$(\
  26. 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 \
  27. 3>&1 1>&2 2>&3 3>&- \
  28. )
  29. title=$(\
  30. 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 \
  31. 3>&1 1>&2 2>&3 3>&- \
  32. )
  33. # Sets the repo type and other variables for the sed regex.
  34. if [[ "$service" == "gmail.com" ]];
  35. then
  36. type="Gmail"
  37. delet="remotehost"
  38. else
  39. type="IMAP"
  40. delet="Gmail]\/"
  41. fi
  42. # The replacements
  43. replacement="
  44. s/\$realname/$realname/g;
  45. s/\$title/$title/g;
  46. s/\$fulladdr/$fulladdr/g;
  47. s/\$imap/$imap/g;
  48. s/\$iport/$iport/g;
  49. s/\$smtp/$smtp/g;
  50. s/\$sport/$sport/g;
  51. s/\$spoolfile/$spoolfile/g;
  52. s/\$postponed/$postponed/g;
  53. s/\$record/$record/g;
  54. s/\$type/$type/g;
  55. /$delet/d"
  56. addAccount() {
  57. # First, adding the encrypted password.
  58. dialog --title "Luke's mutt/offlineIMAP password wizard" --passwordbox "Enter the password for the \"$title\" account." 10 60 2> /tmp/$title
  59. gpg -r $youremail --encrypt /tmp/$title
  60. shred -u /tmp/$title && echo "Password encrypted and memory shredded."
  61. mv /tmp/$title.gpg ~/.config/mutt/credentials/
  62. # Creating the offlineimaprc if it doesn't exist already.
  63. if [ ! -f ~/.offlineimaprc ]; then cp "$muttdir"autoconf/offlineimap_header ~/.offlineimaprc; fi
  64. cat "$muttdir"autoconf/offlineimap_profile | sed -e "$replacement" >> ~/.offlineimaprc
  65. # Add the mutt profile.
  66. cat "$muttdir"autoconf/mutt_profile | sed -e "$replacement" > "$muttdir"accounts/$title.muttrc
  67. # Add on offlineimaprc sync list.
  68. sed -i "s/^accounts =.*[a-zA-Z]$/&, $title/g;s/^accounts =$/accounts = $title/g" ~/.offlineimaprc ;}
  69. addAccount
  70. clear