mail improvements
authorIan Kelling <ian@iankelling.org>
Sat, 20 Jul 2019 22:20:15 +0000 (18:20 -0400)
committerIan Kelling <ian@iankelling.org>
Sat, 20 Jul 2019 22:20:15 +0000 (18:20 -0400)
brc
filesystem/usr/local/bin/zelous-unattended-reboot
mail-setup
pkgs
subdir_files/sieve/lists.sieve
subdir_files/sieve/liststest.sieve [new file with mode: 0644]
subdir_files/sieve/maintest.sieve

diff --git a/brc b/brc
index b232c9ed97d893933b71d597524481b265edcd69..9e9752c18d33c9da89120b008acbcd9892d82a1d 100644 (file)
--- 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
index 8b7b601bbea712fb7e624ff469b9eef0b27a634c..a4672f38b9e6f1034f0157f46fbf5fdfd9f5b786 100755 (executable)
@@ -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
index c062362c18b70409db760268fc74a0ef40ea167b..2af69b27f7411710b2b2efce87bccbc7c528d575 100755 (executable)
@@ -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 <<EOF
 # Mail Server configuration
 # -------------------------
@@ -769,6 +780,15 @@ EOF
   systemctl restart dovecot
 
 else # $HOSTNAME != $MAIL_HOST
+  # remove mail. 2 lines to properly remove whitespace
+  sed -ri -f - /etc/hosts <<'EOF'
+s#^(127\.0\.1\.1 .*) +mail\.iankelling\.org$#\1#
+s#^(127\.0\.1\.1 .*)mail\.iankelling\.org +(.*)#\1\2#
+EOF
+
+  echo | /a/exe/cedit mail /etc/dnsmasq-servers.conf || [[ $? == 1 ]]
+  systemctl reload dnsmasq
+
   systemctl disable offlineimapsync.timer &>/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 7c56a7896680adf0bdcf62fc5142875561013c90..eae95c34e87e89640c4085151208607028eef144 100644 (file)
--- a/pkgs
+++ b/pkgs
@@ -179,6 +179,7 @@ p4=(
   telnet
   transmission-remote-gtk
   trash-cli
+  uptimed
   vlc
   w3m
   whois
index 6cc19db41f2c3977694e3fd9551e34ef028d071b..dd5bb1afdc4fcb8b071d9fdb989e7d0320d603ee 100644 (file)
@@ -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" "<mentors.lists.outreachy.org>"
@@ -35,6 +41,7 @@ if anyof (
     header :contains "list-id" "<libreplanet-discuss.libreplanet.org>",
     header :contains "list-id" "<linux-btrfs.vger.kernel.org>",
     header :contains "list-id" "<linux-fai.uni-koeln.de>",
+    header :contains "list-id" "<license-discuss.lists.opensource.org>",
     header :contains "list-id" "<linux-fai-devel.uni-koeln.de>",
     header :contains "list-id" "<linux-libre.fsfla.org>",
     header :contains "list-id" "<maru-os-dev.googlegroups.com>",
diff --git a/subdir_files/sieve/liststest.sieve b/subdir_files/sieve/liststest.sieve
new file mode 100644 (file)
index 0000000..dd5bb1a
--- /dev/null
@@ -0,0 +1,110 @@
+require [ "regex", "variables", "fileinto", "envelope", "mailbox", "imap4flags", "include" ];
+
+if anyof (
+    header :contains "list-id" "<debian-security-announce.lists.debian.org>",
+    header :contains "list-id" "<ubuntu-security-announce.lists.ubuntu.com>"
+    ) {
+    fileinto :create "sec";
+    stop;
+         }
+if anyof (
+    header :regex "list-id" "forum.members.fsf.org>"
+    ) {
+    fileinto :create "fsfmembers";
+    stop;
+         }
+
+if anyof (
+    header :contains "list-id" "<mentors.lists.outreachy.org>"
+    ) {
+    fileinto :create "l/outreachy-mentors";
+    stop;
+         }
+
+if anyof (
+    header :contains "list-id" "<bbdb-info.lists.sourceforge.net>",
+    header :contains "list-id" "<bug-bash.gnu.org>",
+    header :contains "list-id" "<bug-gnu-emacs.gnu.org>",
+    header :contains "list-id" "<debian-backports.lists.debian.org>",
+    header :contains "list-id" "<debian-security-announce.lists.debian.org>",
+    header :contains "list-id" "<debian-user.lists.debian.org>",
+    header :contains "list-id" "<ding.gnus.org>",
+    header :contains "list-id" "<emacs-devel.gnu.org>",
+    header :contains "list-id" "<emacs-orgmode.gnu.org>",
+    header :contains "list-id" "<git.vger.kernel.org>",
+    header :contains "list-id" "<help-bash.gnu.org>",
+    header :contains "list-id" "<help-gnu-emacs.gnu.org>",
+    header :contains "list-id" "<hyperkitty-devel.lists.fedorahosted.org>",
+    header :contains "list-id" "<ipxe-devel.lists.ipxe.org>",
+    header :contains "list-id" "<kplug-list.kernel-panic.org>",
+    header :contains "list-id" "<kplug-newbie.kernel-panic.org>",
+    header :contains "list-id" "<libreplanet-discuss.libreplanet.org>",
+    header :contains "list-id" "<linux-btrfs.vger.kernel.org>",
+    header :contains "list-id" "<linux-fai.uni-koeln.de>",
+    header :contains "list-id" "<license-discuss.lists.opensource.org>",
+    header :contains "list-id" "<linux-fai-devel.uni-koeln.de>",
+    header :contains "list-id" "<linux-libre.fsfla.org>",
+    header :contains "list-id" "<maru-os-dev.googlegroups.com>",
+    header :contains "list-id" "<mediawiki-l.lists.wikimedia.org>",
+    header :contains "list-id" "<pywikibot.lists.wikimedia.org>",
+    header :contains "list-id" "<pywikipedia-l.lists.wikimedia.org>",
+    header :contains "list-id" "<unison-hackers.lists.seas.upenn.edu>",
+    header :contains "list-id" "<unison-users.yahoogroups.com>",
+    header :contains "list-id" "<whispersystems.lists.riseup.net>",
+    header :contains "list-id" "<wikitech-l.lists.wikimedia.org>",
+    header :contains "list-id" "<xapian-devel.lists.xapian.org>",
+    header :contains "list-id" "<kdeconnect.kde.org>",
+    header :contains "list-id" "<mu-discuss.googlegroups.com>",
+    header :contains "list-id" "<<devel.mediagoblin.org>",
+    header :contains "list-id" "<maru-os.googlegroups.com>",
+    header :contains "list-id" "<listhelper-moderate.nongnu.org>",
+    header :contains "list-id" "<coreboot.coreboot.org>",
+    header :contains "list-id" "<mailman-users.python.org>",
+    header :contains "list-id" "<duplicity-talk.nongnu.org>",
+    header :contains "list-id" "<qemu-devel.nongnu.org>",
+    header :contains "list-id" "<exim-dev.exim.org>",
+    header :contains "list-id" "<exim-users.exim.org>",
+    header :contains "list-id" "<octave-maintainers.gnu.org>",
+    header :contains "list-id" "<discuss-gnuradio.gnu.org>",
+    header :contains "list-id" "<seabios.seabios.org>",
+    header :contains "list-id" "<freetype-devel.nongnu.org>",
+    header :contains "list-id" "<xmonad.haskell.org>") {
+    if header :regex "list-id" "<([a-z_0-9-]+)[.@]" {
+        set :lower "listname" "${1}";
+        fileinto :create "l/${listname}";
+        }
+         }
+if anyof (
+    header :contains "list-id" "<websites.lists.fedoraproject.org>",
+    header :contains "list-id" "<docs.lists.fedoraproject.org>",
+    header :contains "list-id" "<users.lists.fedoraproject.org>") {
+    if header :regex "list-id" "<([a-z_0-9-]+)[.@]" {
+        set :lower "listname" "${1}";
+        fileinto :create "l/fedora.${listname}";
+        }
+         }
+
+if anyof (
+    header :contains "list-id" "<activists_masspirates.org.lists.mayfirst.org>",
+    header :contains "list-id" "<gnu-prog-discuss.gnu.org>",
+    header :contains "list-id" "<gnu-prog.gnu.org>",
+    header :contains "list-id" "<gnu-community-private.gnu.org>",
+    header :contains "list-id" "<gvc.gnu.org>",
+    header :contains "list-id" "<discuss.blu.org>",
+    header :contains "list-id" "<Spdx-tech.lists.spdx.org>",
+    header :contains "list-id" "<Spdx-legal.lists.spdx.org>",
+    header :contains "list-id" "<info-gnu.gnu.org>",
+    header :contains "from" "<general-info@artisansasylum.com>",
+    header :contains "list-id" "<spdx.lists.spdx.org>"
+    ) {
+    fileinto :create "community";
+    stop;
+         }
+
+if allof (
+    address :is "from" "mailman-owner@zope.org",
+    header :is "subject" "zope.org mailing list memberships reminder"
+    ) {
+    discard;
+    stop;
+         }
index 431fd674aae516e84d16dad4fb8294812fece0bc..d7e749bdd2205e88f8a32fe2c1e82f8c2323d138 100644 (file)
@@ -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