Mutt - use common install

This commit is contained in:
unman 2024-03-13 01:06:05 +00:00
parent a3398a8451
commit c1079f376f
No known key found for this signature in database
GPG Key ID: FDD1B8244731B36C
6 changed files with 6 additions and 279 deletions

View File

@ -1,7 +1,8 @@
Name: 3isec-qubes-mutt
Version: 1.1
Version: 2.0
Release: 1%{?dist}
Summary: Prepares qube for using mutt in Qubes
Requires: 3isec-qubes-common
License: GPLv3+
SOURCE0: mutt
@ -23,7 +24,7 @@ cp -rv %{SOURCE0}/ %{buildroot}/srv/salt
%post
if [ $1 -eq 1 ]; then
qubesctl state.apply mutt.clone
qubesctl --skip-dom0 --targets=template-mutt state.apply mutt.install
qubesctl --skip-dom0 --targets=template-mutt state.apply 3isec-common.mutt.install
qubesctl state.apply mutt.configure
fi
@ -31,7 +32,9 @@ fi
%changelog
* Mon Mar 11 2024 unman <unman@thirdeyesecurity.org> - 2.0
- Move common mutt install files to 3isec-common package
* Mon Feb 20 2023 unman <unman@thirdeyesecurity.org> - 1.1
- Use pillar for cacher to determine repo changes
* Wed Jul 15 2021 unman <unman@thirdeyesecurity.org>
* Wed Jul 14 2021 unman <unman@thirdeyesecurity.org>
- First Build

View File

@ -1,80 +0,0 @@
# vim: set syntax=yaml ts=2 sw=2 sts=2 et :
#
{% if grains['nodename'] != 'dom0' %}
{% if salt['pillar.get']('update_proxy:caching') %}
{% for repo in salt['file.find']('/etc/apt/sources.list.d/', name='*list') %}
{{ repo }}_baseurl:
file.replace:
- name: {{ repo }}
- pattern: 'https://'
- repl: 'http://HTTPS///'
- flags: [ 'IGNORECASE', 'MULTILINE' ]
- backup: False
{% endfor %}
/etc/apt/sources.list:
file.replace:
- names:
- /etc/apt/sources.list
- pattern: 'https://'
- repl: 'http://HTTPS///'
- flags: [ 'IGNORECASE', 'MULTILINE' ]
{% endif %}
update:
pkg.uptodate:
- refresh: True
installed:
pkg.installed:
- pkgs:
- qubes-core-agent-networking
- qubes-app-shutdown-idle
- qubes-gpg-split
- mb2md
- mutt
- notmuch
- notmuch-mutt
- offlineimap3
- openssh-client
- rsync
- w3m
- zenity
- skip_suggestions: True
- install_recommends: False
change_timeout:
file.replace:
- name: /usr/lib/python3/dist-packages/qubesidle/idleness_monitor.py
- pattern: '15 * 60'
- repl: '3 * 60'
- flags: [ 'IGNORECASE', 'MULTILINE' ]
default_muttrc:
file.managed:
- name: /etc/skel/.muttrc
- source: salt://mutt/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
helper_script_menu:
file.managed:
- name: /usr/share/applications/mutt_setup.desktop
- source: salt://mutt/mutt_setup.desktop
- user: user
- group: user
- mode: 755
{% endif %}

View File

@ -1,5 +0,0 @@
# vim: set syntax=yaml ts=2 sw=2 sts=2 et :
base:
template-mutt:
- mutt.install

View File

@ -1,10 +0,0 @@
#!/usr/bin/env xdg-open
[Desktop Entry]
Categories=Office;Network;Email;
Comment=Simple configuration for mutt
Exec=/home/user/setup_mutt.sh
Icon=mutt
Name=Setup_mutt
Terminal=false
Type=Application

View File

@ -1,79 +0,0 @@
##############################
### USER CONFIGURATION ###
# UNCOMMENT THE RELEVANT LINES AND INSERT YOUR DETAILS
## PGP
# Specify what key to use for signing here:
#set pgp_sign_as=0x
## END PGP
## IMAP
#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://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=SMTP_USERNAME
#set smtp_url=smtps://$my_user@SMTP_SERVER
#set ssl_force_tls=yes
#set record= +Sent
#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 ###
##############################
set pgp_use_gpg_agent = no
set crypt_use_gpgme=no
# decode application/pgp
set pgp_decode_command="qubes-gpg-client-wrapper -d --status-fd=2 --batch %f"
# decrypt a pgp/mime attachment
set pgp_decrypt_command="$pgp_decode_command"
# verify a pgp/mime signature
#set pgp_verify_command="gpg --status-fd=2 --no-verbose --quiet --batch --output - --verify %s %f"
set mbox_type=Maildir
set record=+mail
set header_cache = "/home/user/.cache/Mail/headers"
set editor="vi -c ':set tw=72' "
set pager_index_lines=10
color index green black ~N
color index yellow black ~O
macro index <F8> \
"<enter-command>set my_old_pipe_decode=\$pipe_decode my_old_wait_key=\$wait_key nopipe_decode nowait_key<enter>\
<shell-escape>notmuch-mutt -r --prompt search<enter>\
<change-folder-readonly>`echo ${XDG_CACHE_HOME:-$HOME/.cache}/notmuch/mutt/results`<enter>\
<enter-command>set pipe_decode=\$my_old_pipe_decode wait_key=\$my_old_wait_key<enter>" \
"notmuch: search mail"
macro index <F9> \
"<enter-command>set my_old_pipe_decode=\$pipe_decode my_old_wait_key=\$wait_key nopipe_decode nowait_key<enter>\
<pipe-message>/usr/bin/notmuch-mutt -r thread<enter> \
<change-folder-readonly>/home/user/.cache/notmuch/mutt/results<enter> \
<enter-command>set pipe_decode=\$my_old_pipe_decode wait_key=\$my_old_wait_key<enter>" \
"notmuch: reconstruct thread"

View File

@ -1,102 +0,0 @@
#!/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