mirror of
https://github.com/unman/shaker.git
synced 2024-12-27 00:09:41 -05:00
Mutt - include helper script
This commit is contained in:
parent
448562d481
commit
a659e3a188
@ -30,10 +30,11 @@ installed:
|
||||
- mutt
|
||||
- notmuch
|
||||
- notmuch-mutt
|
||||
- offline-imap
|
||||
- offlineimap3
|
||||
- openssh-client
|
||||
- rsync
|
||||
- w3m
|
||||
- zenity
|
||||
- skip_suggestions: True
|
||||
- install_recommends: False
|
||||
|
||||
@ -51,4 +52,12 @@ default_muttrc:
|
||||
- user: user
|
||||
- group: user
|
||||
|
||||
helper_script:
|
||||
file.managed:
|
||||
- name: /etc/skel/setup_mutt.sh
|
||||
- source: salt://mutt/setup_mutt.sh
|
||||
- user: user
|
||||
- group: user
|
||||
- mode: 744
|
||||
|
||||
{% endif %}
|
||||
|
28
mutt/muttrc
28
mutt/muttrc
@ -5,36 +5,40 @@
|
||||
## PGP
|
||||
# Specify what key to use for signing here:
|
||||
#set pgp_sign_as=0x
|
||||
## END PGP
|
||||
|
||||
|
||||
## IMAP
|
||||
#set folder=imaps://YOUR_SERVER/
|
||||
#set imap_user=YOUR_USERNAME_HERE
|
||||
#set imap_pass=YOUR_PASSWORD_HERE
|
||||
#set folder=imaps://IMAP_SERVER/
|
||||
#set imap_user=IMAP_USERNAME
|
||||
#set imap_pass=IMAP_PASSWORD
|
||||
#set spoolfile=+INBOX
|
||||
#set imap_check_subscribed
|
||||
## END IMAP
|
||||
|
||||
|
||||
## POP3
|
||||
#set pop_host=pops://YOUR_SERVER
|
||||
#set pop_user=YOUR_USERNAME_HERE
|
||||
#set pop_pass=YOUR_PASSWORD_HERE
|
||||
#set pop_host=pops://POP3_SERVER
|
||||
#set pop_user=POP3_USERNAME
|
||||
#set pop_pass=POP3_PASSWORD
|
||||
#set pop_checkinterval=120
|
||||
#set pop_delete=ask-no
|
||||
#set pop_last=yes
|
||||
## END POP3
|
||||
|
||||
|
||||
##SMTP
|
||||
#set my_user=YOUR_USERNAME_HERE
|
||||
#set smtp_url=smtps://$my_user@YOUR_SMTP_SERVER
|
||||
## SMTP
|
||||
#set my_user=SMTP_USERNAME
|
||||
#set smtp_url=smtps://$my_user@SMTP_SERVER
|
||||
#set ssl_force_tls=yes
|
||||
#set record= +Sent
|
||||
#set smtp_pass=YOUR_PASSWORD_HERE
|
||||
#set realname=YOUR_REAL_NAME
|
||||
#set from=YOUR_EMAIL_ADDRESS
|
||||
#set smtp_pass=SMTP_PASSWORD
|
||||
#set realname=SMTP_REAL_NAME
|
||||
#set from=EMAIL_ADDRESS
|
||||
#set use_from=yes
|
||||
#set ssl_starttls=yes
|
||||
#set ssl_force_tls=yes
|
||||
## END SMTP
|
||||
|
||||
### END USER CONFIGURATION ###
|
||||
##############################
|
||||
|
102
mutt/setup_mutt.sh
Executable file
102
mutt/setup_mutt.sh
Executable file
@ -0,0 +1,102 @@
|
||||
#!/bin/bash
|
||||
target_file=/home/user/.muttrc
|
||||
|
||||
if grep -q "##CONFIGURED" "$target_file" ; then
|
||||
zenity --question --text="Mutt is already configured\nDo you want to change configuration?" --no-wrap
|
||||
if [ $? = 1 ];then
|
||||
exit
|
||||
else
|
||||
configured=1
|
||||
fi
|
||||
fi
|
||||
|
||||
zenity --question --text="Do you have the details of your mail server ready?"
|
||||
if [ $? = 0 ] ;then
|
||||
|
||||
type="$(zenity --list --title="Connection type" --text="Select the connection type" --radiolist --column=Selection --column="Connection Type" \
|
||||
FALSE "POP3" FALSE "IMAP" )"
|
||||
if [ $? = 1 ]; then
|
||||
exit
|
||||
fi
|
||||
if [ "x$type" == "x" ]; then
|
||||
zenity --warning --text="No connection type selected" --no-wrap
|
||||
exit
|
||||
fi
|
||||
|
||||
zenity --info --text="Now you need to enter the details of your mail server.\nIf you leave the password blank you will be prompted for it each time you connect." --no-wrap
|
||||
details="$(zenity --forms --title='Log in details' \
|
||||
--text='Enter information about your email server' \
|
||||
--add-entry='Server address' \
|
||||
--add-entry='Server port' \
|
||||
--add-entry='Username' \
|
||||
--add-password='Password' )"
|
||||
if [ $? = 1 ]; then
|
||||
exit
|
||||
fi
|
||||
if [[ $details =~ "||" ]]; then
|
||||
zenity --warning --text="Missing information"
|
||||
exit
|
||||
fi
|
||||
|
||||
zenity --info --text="Now you need to enter the details of your SMTP server.\nIf you leave the password blank you will be prompted for it each time you send mail." --no-wrap
|
||||
smtp_details="$(zenity --forms --title='Log in details' \
|
||||
--text='Enter information about your SMTP server' \
|
||||
--add-entry='Name on outgoing emails' \
|
||||
--add-entry='Email address' \
|
||||
--add-entry='Server address' \
|
||||
--add-entry='Server port' \
|
||||
--add-entry='Username' \
|
||||
--add-password='Password' )"
|
||||
if [ $? = 1 ]; then
|
||||
exit
|
||||
fi
|
||||
if [[ $smtp_details =~ "||" ]]; then
|
||||
zenity --warning --text="Missing information"
|
||||
exit
|
||||
fi
|
||||
oldifs=$IFS
|
||||
IFS='|' read -r server_address server_port name pw <<<$details
|
||||
IFS='|' read -r smtp_outname email smtp_address smtp_port smtp_name smtp_pw <<<$smtp_details
|
||||
IFS=$oldifs
|
||||
if [ $type == "POP3" ]; then
|
||||
type=POP
|
||||
fi
|
||||
if [ "x$pw" != "x" ]; then
|
||||
sed -i -E "/$type/,/END $type/ s^(set ${type,,}_pass).*^\1=$pw^ " $target_file
|
||||
else
|
||||
sed -i -E "/$type/,/END $type/ s^(set ${type,,}_pass).*^#\1=^ " $target_file
|
||||
fi
|
||||
sed -i -E -e "/USER CONFIGURATION/,/END USER CONFIGURATION/ s/^([^#])/#\1/ " \
|
||||
-e "/$type/,/END $type/ { //! s/^#// }" \
|
||||
-e "/$type/,/END $type/ s^(set folder.*\/\/).*^\1$server_address:$server_port/^ " \
|
||||
-e "/$type/,/END $type/ s^(set pop_host.*\/\/).*^\1$server_address:$server_port^ " \
|
||||
-e "/$type/,/END $type/ s^(set ${type,,}_user).*^\1=$name^ " $target_file
|
||||
|
||||
sed -i -E -e "/SMTP/,/END SMTP/ { //! s/^#// }" \
|
||||
-e "/SMTP/,/END SMTP/ s^(set my_user=).*^\1$smtp_name^ " \
|
||||
-e "/SMTP/,/END SMTP/ s^(set smtp_url.*\/\/).*^\1\$my_user@$smtp_address:$smtp_port^ " \
|
||||
-e "/SMTP/,/END SMTP/ s^(set realname=).*^\1$smtp_outname^ " \
|
||||
-e "/SMTP/,/END SMTP/ s^(set from=).*^\1$email^ " $target_file
|
||||
if [ "x$smtp_pw" != "x" ]; then
|
||||
sed -i -E "/SMTP/,/END SMTP/ s^(set smtp_pass=).*^\1$smtp_pw^ " $target_file
|
||||
else
|
||||
sed -i -E "/SMTP/,/END SMTP/ s^(set smtp_pass=).*^#\1^ " $target_file
|
||||
fi
|
||||
|
||||
zenity --question --text="Do you use PGP?"
|
||||
if [ $? = 0 ] ;then
|
||||
key=$(zenity --entry --title "PGP key ID" --text "Enter your PGP Key ID 0x....." )
|
||||
else
|
||||
sed -i -E "/PGP/,/END PGP/ s/^(set pgp_sign_as=).*/#\1/ " $target_file
|
||||
fi
|
||||
if [ "x$key" != "x" ]; then
|
||||
sed -i -E "/PGP/,/END PGP/ s^.*(set pgp_sign_as=).*^\1$key^ " $target_file
|
||||
fi
|
||||
if [ $configured != 1 ];then
|
||||
sed -i '1 i ##CONFIGURED ' $target_file
|
||||
fi
|
||||
exit
|
||||
else
|
||||
zenity --error --text="You need those details to set up mutt."
|
||||
exit
|
||||
fi
|
Loading…
Reference in New Issue
Block a user