From: Ian Kelling Date: Sat, 20 Jul 2019 22:20:15 +0000 (-0400) Subject: mail improvements X-Git-Url: https://iankelling.org/git/?p=distro-setup;a=commitdiff_plain;h=ae54f4cd08815de501151c10083e74294609558a mail improvements --- diff --git a/brc b/brc index b232c9e..9e9752c 100644 --- a/brc +++ b/brc @@ -1806,9 +1806,8 @@ testmail() { # MSG_ID is in /var/log/exim4/mainlog, looks like 1ccdnD-0001nh-EN } -# to test sieve, use below command. for fsf mail, see fsf-get-mail script. +# to test sieve, use below command. for fsf mail, see offlineimap-sync script # make modifications, then copy to live file, use -eW to actually modify mailbox -# cp /p/c/subdir_files/sieve/personal{test,}.sieve; testsievelist -eW INBOX # # Another option is to use sieve-test SCRIPT MAIL_FILE. note, # sieve-test doesnt know about envelopes, Im not sure if sieve-filter does. @@ -1816,15 +1815,17 @@ testmail() { # sieve with output filter. arg is mailbox, like INBOX. # This depends on dovecot conf, notably mail_location in /etc/dovecot/conf.d/10-mail.conf -testsievelist() { - sieve-filter ~/sieve/maintest.sieve "$@" >/tmp/testsieve.log 2> >(tail) && sed -rn '/^Performed actions:/{n;n;p}' /tmp/testsieve.log | sort -u +_dosieve() { + sieve-filter "$@" 2> >(head; tail) >/tmp/testsieve.log && sed -rn '/^Performed actions:/,/^[^ ]/{/^ /p}' /tmp/testsieve.log | sort | uniq -c } - -# mail related -# plain sieve +# always run this first, edit the test files, then run the following testsieve() { - sieve-filter ~/sieve/main.sieve "$@" + _dosieve ~/sieve/maintest.sieve INBOX delete +} +runsieve() { + c ~/sieve; cp personal{test,}.sieve; cp lists{test,}.sieve + _dosieve ~/sieve/main.sieve -eW INBOX delete } # mail related diff --git a/filesystem/usr/local/bin/zelous-unattended-reboot b/filesystem/usr/local/bin/zelous-unattended-reboot index 8b7b601..a4672f3 100755 --- a/filesystem/usr/local/bin/zelous-unattended-reboot +++ b/filesystem/usr/local/bin/zelous-unattended-reboot @@ -1,7 +1,7 @@ #!/bin/bash if [[ $(/usr/sbin/checkrestart | wc -l) != 1 ]]; then for x in {30..1}; do - echo "pid $PID. unattended upgrade, rebooting in $((x*10)) seconds" | wall + echo "pid $PID. unattended upgrade, rebooting in $((x*10)) seconds" | wall -n sleep 10 done for x in {30..1}; do @@ -9,8 +9,8 @@ if [[ $(/usr/sbin/checkrestart | wc -l) != 1 ]]; then /sbin/reboot exit 0 fi - echo "pid $PID. unattended upgrade reboot waiting 10 seconds for dpkg lock" | wall + echo "pid $PID. unattended upgrade reboot waiting 10 seconds for dpkg lock" | wall -n sleep 10 done - echo "dpkg locked for 5 minutes, automatic reboot failed" | pee cat wall + echo "pid $PID. dpkg locked for 5 minutes, automatic reboot failed" | pee cat "wall -n" fi diff --git a/mail-setup b/mail-setup index c062362..2af69b2 100755 --- a/mail-setup +++ b/mail-setup @@ -474,6 +474,17 @@ systemctl enable mailcert.timer if [[ $HOSTNAME == $MAIL_HOST ]]; then + # mail.iankelling.org so local imap clients can connect with tls and + # when they happen to not be local. + sed -ri -f - /etc/hosts <<'EOF' +/^127\.0\.1\.1.* mail\.iankelling\.org\b/q +/^127\.0\.1\.1 /s/ *$/ mail.iankelling.org/ +EOF + /a/exe/cedit mail /etc/dnsmasq-servers.conf <<'EOF' || [[ $? == 1 ]] +server=/mail.iankelling.org/127.0.1.1 +EOF + systemctl reload dnsmasq + debconf-set-selections </dev/null ||: systemctl stop offlineimapsync.timer &>/dev/null ||: systemctl disable mailclean.timer &>/dev/null ||: @@ -918,12 +938,29 @@ fi dir=/nocow/exim4 sdir=/var/spool/exim4 # we only do this if our system has $dir -if [[ -e /nocow && $(readlink -f $sdir) != $dir ]]; then - systemctl stop exim4 - if [[ ! -e $dir && -d $sdir ]]; then - mv $sdir $dir + +# this used to do a symlink, but, in the boot logs, /nocow would get mounted succesfully, +# about 2 seconds later, exim starts, and immediately puts into paniclog: +# honVi-0000u3-82 Failed to create directory "/var/spool/exim4/input": No such file or directory +# so, im trying a bind mount to get rid of that. +if [[ -e /nocow ]]; then + if ! grep -Fx "/nocow/exim4 /var/spool/exim4 none bind 0 0" /etc/fstab; then + echo "/nocow/exim4 /var/spool/exim4 none bind 0 0" >> /etc/fstab + fi + if ! mountpoint -q $sdir; then + systemctl stop exim4 + if [[ -L $sdir ]]; then + rm $sdir + fi + if [[ ! -e $dir && -d $sdir ]]; then + mv $sdir $dir + fi + if [[ ! -d $sdir ]]; then + mkdir $sdir + chmod 000 $sdir # only want it to be used when its mounted + fi + mount $sdir fi - /a/exe/lnf -T $dir $sdir fi systemctl restart exim4 diff --git a/pkgs b/pkgs index 7c56a78..eae95c3 100644 --- a/pkgs +++ b/pkgs @@ -179,6 +179,7 @@ p4=( telnet transmission-remote-gtk trash-cli + uptimed vlc w3m whois diff --git a/subdir_files/sieve/lists.sieve b/subdir_files/sieve/lists.sieve index 6cc19db..dd5bb1a 100644 --- a/subdir_files/sieve/lists.sieve +++ b/subdir_files/sieve/lists.sieve @@ -7,6 +7,12 @@ if anyof ( fileinto :create "sec"; stop; } +if anyof ( + header :regex "list-id" "forum.members.fsf.org>" + ) { + fileinto :create "fsfmembers"; + stop; + } if anyof ( header :contains "list-id" "" @@ -35,6 +41,7 @@ if anyof ( header :contains "list-id" "", header :contains "list-id" "", header :contains "list-id" "", + header :contains "list-id" "", header :contains "list-id" "", header :contains "list-id" "", header :contains "list-id" "", diff --git a/subdir_files/sieve/liststest.sieve b/subdir_files/sieve/liststest.sieve new file mode 100644 index 0000000..dd5bb1a --- /dev/null +++ b/subdir_files/sieve/liststest.sieve @@ -0,0 +1,110 @@ +require [ "regex", "variables", "fileinto", "envelope", "mailbox", "imap4flags", "include" ]; + +if anyof ( + header :contains "list-id" "", + header :contains "list-id" "" + ) { + fileinto :create "sec"; + stop; + } +if anyof ( + header :regex "list-id" "forum.members.fsf.org>" + ) { + fileinto :create "fsfmembers"; + stop; + } + +if anyof ( + header :contains "list-id" "" + ) { + fileinto :create "l/outreachy-mentors"; + stop; + } + +if anyof ( + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "<", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "") { + if header :regex "list-id" "<([a-z_0-9-]+)[.@]" { + set :lower "listname" "${1}"; + fileinto :create "l/${listname}"; + } + } +if anyof ( + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "") { + if header :regex "list-id" "<([a-z_0-9-]+)[.@]" { + set :lower "listname" "${1}"; + fileinto :create "l/fedora.${listname}"; + } + } + +if anyof ( + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "list-id" "", + header :contains "from" "", + header :contains "list-id" "" + ) { + fileinto :create "community"; + stop; + } + +if allof ( + address :is "from" "mailman-owner@zope.org", + header :is "subject" "zope.org mailing list memberships reminder" + ) { + discard; + stop; + } diff --git a/subdir_files/sieve/maintest.sieve b/subdir_files/sieve/maintest.sieve index 431fd67..d7e749b 100644 --- a/subdir_files/sieve/maintest.sieve +++ b/subdir_files/sieve/maintest.sieve @@ -14,6 +14,7 @@ if header :regex "x-spam_bar" "^\\+{5}" { } include :personal "personaltest"; +include :personal "liststest"; # note, i originally used something like this to filter mailing lists