various fixes and improvements, several email stuff
authorIan Kelling <ian@iankelling.org>
Thu, 30 Mar 2017 23:27:47 +0000 (16:27 -0700)
committerIan Kelling <ian@iankelling.org>
Thu, 30 Mar 2017 23:27:53 +0000 (16:27 -0700)
.dovecot.sieve [deleted file]
.gdbinit [new file with mode: 0644]
filesystem/etc/cron.weekly/btrfs-balance-ian
filesystem/etc/dovecot/conf.d/20-lmtp.conf
filesystem/etc/dovecot/local.conf
filesystem/etc/exim4/conf.d/router/900_exim4-config_local_user [new file with mode: 0644]
filesystem/etc/exim4/conf.d/router/950_exim4-config_local_catchall [deleted file]
filesystem/etc/profile.d/environment.sh [new file with mode: 0644]
filesystem/etc/systemd/system.conf.d/tz.conf [new file with mode: 0644]
subdir_files/.xmonad/xmonad.hs
subdir_files/sieve/main.sieve [new file with mode: 0644]

diff --git a/.dovecot.sieve b/.dovecot.sieve
deleted file mode 100644 (file)
index fb852bc..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-# Sieve filter
-##
-require [ "regex", "variables", "fileinto", "envelope", "mailbox", "imap4flags" ];
-
-# Mailinglist Killfile
-if anyof (header :contains "from" "unwanted at example.com",
-          header :contains "from" "spammer at example.net",
-          header :contains "from" "troll at example.org"){
-       discard;
-       stop;
-}
-
-if anyof (header :contains "x-spam-flag" "yes",
-          allof (header :regex "X-DSPAM-Result" "^(Spam|Virus|Bl[ao]cklisted)$",
-                 not header :contains "X-DSPAM-Reclassified" "Innocent")){
-       # Spam goes into the spam folder
-       setflag "\\Seen";
-       fileinto :create "spam";
-       stop;
-}
-
-# split out the various list forms
-# Mailman & other lists using list-id
-if exists "list-id" {
-    if header :regex "list-id" "<([a-z_0-9-]+)[.@]" {
-        set :lower "listname" "${1}";
-        fileinto :create "${listname}";
-    } elsif header :regex "list-id" "^\\s*<?([a-z_0-9-]+)[.@]" {
-        set :lower "listname" "${1}";
-        fileinto :create "${listname}";
-    } else {
-        keep;
-    }
-    stop;}
-# Listar and mailman like
-elsif exists "x-list-id" {
-    if header :regex "x-list-id" "<([a-z_0-9-]+)\\\\." {
-        set :lower "listname" "${1}";
-        fileinto :create "${listname}";
-    } else {
-        keep;
-    }
-    stop;}
-# Ezmlm
-elsif exists "mailing-list" {
-    if header :regex "mailing-list" "([a-z_0-9-]+)@" {
-        set :lower "listname" "${1}";
-        fileinto :create "${listname}";
-    } else {
-        keep;
-    }
-    stop;}
-# York lists service
-elsif exists "x-mailing-list" {
-    if header :regex "x-mailing-list" "^\\s*([a-z_0-9-]+)@?" {
-        set :lower "listname" "${1}";
-        fileinto :create "${listname}";
-    } else {
-        keep;
-    }
-    stop;}
-# Smartlist
-elsif exists "x-loop" {
-       if header :regex "x-loop" "^\\s*(a-z_0-9-]+)@?" {
-               set :lower "listname" "${1}";
-               fileinto :create "${listname}";
-       } else {
-           keep;
-       }
-    stop;}
-# poorly identified
-elsif envelope :contains "from" "owner-" {
-    if envelope :regex "from" "owner-([a-z_0-9-]+)-outgoing@" {
-        set :lower "listname" "${1}";
-        fileinto :create "${listname}";
-    } elsif envelope :regex "from" "owner-([a-z_0-9-]+)@" {
-        set :lower "listname" "${1}";
-        fileinto :create "${listname}";
-    } elsif header :regex "Sender" "owner-([a-z_0-9-]+)@" {
-        set :lower "listname" "${1}";
-        fileinto :create "${listname}";
-    } else {
-        keep;
-    }
-    stop;}
-# other poorly identified
-elsif  envelope :contains "from" "-request" {
-    if envelope :regex "from" "([a-z_0-9-]+)-request@" {
-        set :lower "listname" "${1}";
-        fileinto :create "${listname}";
-    } else {
-        keep;
-    }
-    stop;
-}
diff --git a/.gdbinit b/.gdbinit
new file mode 100644 (file)
index 0000000..5c6ecb8
--- /dev/null
+++ b/.gdbinit
@@ -0,0 +1,13 @@
+
+# based on this gdb output:
+# warning: File "/a/opt/emacs-debiantesting/src/.gdbinit" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
+# To enable execution of this file add
+# add-auto-load-safe-path /a/opt/emacs-debiantesting/src/.gdbinit
+# line to your configuration file "/home/ian/.gdbinit".
+# To completely disable this security protection add
+# set auto-load safe-path /
+# line to your configuration file "/home/ian/.gdbinit".
+# For more information about this security protection see the
+# "Auto-loading safe path" section in the GDB manual.  E.g., run from the shell:
+# info "(gdb)Auto-loading safe path"
+set auto-load safe-path /
index 7447740303de05bcd0bec0cfcb36bbd02bbd6bc8..3061f3a1b730793a045fa5c86eae10e36bc61cc0 100755 (executable)
@@ -12,33 +12,32 @@ trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
 dusage="1 5 10 20 30 40 50"
 musage="1 5 10 20 30"
 
-e() { echo "$*"; "$@"; }
+e() { echo "cron: $*"; "$@"; }
 
 fnd="findmnt --types btrfs --noheading"
 for x in $($fnd --output "SOURCE" --nofsroot | sort -u); do
     mnt=$($fnd --output "TARGET" --first-only --source $x)
     [[ $mnt ]] || continue
-    echo "Before balance of $mnt"
-    e btrfs filesystem df $mnt
-    df -H $mnt
+    # for comparing before and after balance.
+    # the log is already fairly verbose, so commented.
+    # e btrfs filesystem df $mnt
+    # e df -H $mnt
     if btrfs filesystem df $mnt | grep -q "Data+Metadata"; then
         for usage in $dusage; do
-            e btrfs balance start -v -dusage=$usage -musage=$usage $mnt
+            e btrfs balance start -dusage=$usage -musage=$usage $mnt
         done
     else
         e btrfs balance start -dusage=0 $mnt
         for usage in $dusage; do
-            e btrfs balance start -v -dusage=$usage $mnt
+            e btrfs balance start -dusage=$usage $mnt
         done
         e btrfs balance start -musage=0 $mnt
         for usage in $musage; do
-            e btrfs balance start -v -musage=$usage $mnt
+            e btrfs balance start -musage=$usage $mnt
         done
     fi
-    echo "After balance of $mnt"
-    btrfs filesystem df $mnt
-    df -H $mnt
-
+    # e btrfs filesystem df $mnt
+    # e df -H $mnt
     date=$(
         btrfs scrub status $mnt | \
             sed -rn 's/^\s*scrub started at (.*) and finished.*/\1/p'
@@ -50,9 +49,9 @@ for x in $($fnd --output "SOURCE" --nofsroot | sort -u); do
         # it makes the comp lag like shit for a day,
         # so I'm going with 90 days.
         if (( $date > `date +%s` - 60*60*24*30 )); then
-            echo "skiping scrub of $mnt"
+            echo "cron: skiping scrub of $mnt"
             continue
         fi
     fi
-    btrfs scrub start -Bd $mnt
+    btrfs scrub start -Bd $mnt
 done
index 0955b17ecd26b93cb0acf292600bc0374b14bf50..43acd1d55cf53155304e6d0c5ca94270df60c699 100644 (file)
@@ -28,9 +28,31 @@ protocol lmtp {
   mail_plugins = $mail_plugins sieve
 
 
-# ian: added this, based on errors and some googling.
-# Exim says something like "LMTP error after RCPT ... 550 ... User doesn't exist someuser@somedomain"
-# Dovecot verbose log says something like "auth-worker(9048): passwd(someuser@somedomain): unknown user"
+# For a normal setup, we need something like this, which
+# removes the domain part
+#  auth_username_format = %Ln
+#
+#  or else # Exim says something like
+#  "LMTP error after RCPT ... 550 ... User doesn't exist someuser@somedomain"
+# Dovecot verbose log says something like
+# "auth-worker(9048): passwd(someuser@somedomain): unknown user"
 # reference: http://wiki.dovecot.org/LMTP/Exim
-  auth_username_format = %Ln
+#
+# However, I use this to direct all mail to the same inbox.
+# A more normal way to do this, which I did at first is to have
+# a router in exim almost at the end, eg 950,
+#local_catchall:
+#  debug_print = "R: catchall for $local_part@$domain"
+#  driver = redirect
+#  domains = +local_domains
+#  data = ian
+# based on
+# http://blog.alteholz.eu/2015/04/exim4-and-catchall-email-address/
+# with superflous options removed.
+# However, this causes the envelope to be rewritten,
+# which makes filtering into mailboxes a little less robust or more complicated,
+# so I've done it this way instead. it also requires
+# modifying the local router in exim.
+#
+  auth_username_format = ian
 }
index 95536f2a5c5c16be2dab60a64a85412b8f6f1fc1..830338005fa7e5dea5ed192e147834425d53ee34 100644 (file)
@@ -17,4 +17,4 @@ ssl_prefer_server_ciphers = yes
 # for debugging info, uncomment these.
 # logs go to syslog, and to /var/log/mail.log
 # auth_verbose=yes
-mail_debug=yes
+#mail_debug=yes
diff --git a/filesystem/etc/exim4/conf.d/router/900_exim4-config_local_user b/filesystem/etc/exim4/conf.d/router/900_exim4-config_local_user
new file mode 100644 (file)
index 0000000..bfdcf29
--- /dev/null
@@ -0,0 +1,17 @@
+
+### router/900_exim4-config_local_user
+#################################
+
+# This router matches local user mailboxes. If the router fails, the error
+# message is "Unknown user".
+
+local_user:
+  debug_print = "R: local_user for $local_part@$domain"
+  driver = accept
+  domains = +local_domains
+# ian: commented this, in conjunction with a dovecot lmtp
+# change so I get mail for all users.
+#  check_local_user
+  local_parts = ! root
+  transport = LOCAL_DELIVERY
+  cannot_route_message = Unknown user
diff --git a/filesystem/etc/exim4/conf.d/router/950_exim4-config_local_catchall b/filesystem/etc/exim4/conf.d/router/950_exim4-config_local_catchall
deleted file mode 100644 (file)
index eb5121c..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-# redirect anything that hasn't been caught yet to me,
-# based on
-# http://blog.alteholz.eu/2015/04/exim4-and-catchall-email-address/
-# that reference includes the lines allow_fail and allow_defer, but
-# afaik, they are completely superfluous and just copied from another
-# router, they apply when the expansion of data contains :defer: or :fail:,
-# but we are just using a string literal.
-local_catchall:
-  debug_print = "R: catchall for $local_part@$domain"
-  driver = redirect
-  domains = +local_domains
-  data = ian
diff --git a/filesystem/etc/profile.d/environment.sh b/filesystem/etc/profile.d/environment.sh
new file mode 100644 (file)
index 0000000..ed621d6
--- /dev/null
@@ -0,0 +1,69 @@
+export ACME_TINY_WRAPPER_CERT_DIR=/p/c/machine_specific/$HOSTNAME/webservercerts
+export ACME_TINY_PATH="/a/opt/acme-tiny/acme_tiny.py"
+
+if [ -f $HOME/path_add-function ]; then
+    . $HOME/path_add-function
+    path_add /usr/sbin /usr/local/sbin /sbin
+    path_add /a/exe /a/opt/bin $HOME/.cabal/bin
+
+    if [ -r /etc/alternatives/java_sdk ]; then
+        export JAVA_HOME=/etc/alternatives/java_sdk
+        path_add /etc/alternatives/java_sdk
+    fi
+fi
+
+export EDITOR="emacsclient"
+# this makes emacsclient file/-c start a server instance if none is running,
+# instead of some alternate editor logic
+export ALTERNATE_EDITOR=""
+
+
+# makes subsequent syscalls to localtime use cached timezone,
+# so basically restart the comp if you change time zones,
+# and avoid a few syscalls, which makes a tiny tiny perf difference.
+# I also set this in
+# /a/c/filesystem/etc/systemd/system.conf.d/tz.conf
+# https://blog.packagecloud.io/eng/2017/02/21/set-environment-variable-save-thousands-of-system-calls/
+export TZ=:/etc/localtime
+
+# ubuntu starts gpg agent automatically with  /etc/X11/Xsession.d/90gpg-agent.
+# fedora doesn't, which left me to figure this out, and google was no help.
+# fedora documentation is often quite bad :(
+# This is mostly copied from that file.
+# Main difference is that we eval the result of starting gpg-agent,
+# while that file executes it through xsession specific var.
+# Also make sourcing the pidfile make more sense.
+# End result should be the same afaik.
+# for gpg-agent to work when calling gpg from the command line,
+# we need an environment variable that is setup via the eval.
+# which is why we do this upon login, so it can propogate
+# It is also written to the file $HOME/.gnupg/gpg-agent-info-$(hostname)
+# I'm not aware if that is ever used, but just fyi.
+# I also added the bit about xmessaging the stderr,
+# because I'd like to know if the command fails
+if [ -f /etc/fedora-release ]; then
+    : ${GNUPGHOME=$HOME/.gnupg}
+
+    GPGAGENT=/usr/bin/gpg-agent
+    PID_FILE="$GNUPGHOME/gpg-agent-info-$(hostname)"
+
+    if ! $GPGAGENT 2>/dev/null; then
+        temp="$(mktemp)"
+        eval "$($GPGAGENT --homedir /p/do-not-delete --daemon --sh --write-env-file=$PID_FILE 2>$temp)"
+        temperr="$(<"$temp")"
+        [ -n "$temperr" ] && xmessage "gpg-agent stderr: $temperr"
+    elif [ -r "$PID_FILE" ]; then
+        . "$PID_FILE"
+        export GPG_AGENT_INFO
+    fi
+fi
+
+# ubuntu has 002 for non-system users, debian has 022.  002 makes groups
+# be rw instead of r. One security concern is where some unixes put
+# every user in a same group, so if you copy files there with exact
+# perms, that is probably not what you want. I don't use a system like
+# that. I don't care much either way, but the ubuntu one seems a bit
+# more user friendly.
+if (( EUID >= 1000 )); then
+    umask 002
+fi
diff --git a/filesystem/etc/systemd/system.conf.d/tz.conf b/filesystem/etc/systemd/system.conf.d/tz.conf
new file mode 100644 (file)
index 0000000..dcfba45
--- /dev/null
@@ -0,0 +1,3 @@
+[Manager]
+DefaultEnvironment=TZ=:/etc/localtime
+# also set in profile.d/environment.sh with explanation there
index 9ab7becdc3b64b8e7dd1fa2633394d73774bd455..6a0bd5ae15d7e21d1beaaf1c1f806a3c695fb22a 100644 (file)
@@ -1,3 +1,4 @@
+
 import XMonad
 --import XMonad.Config.Gnome
 
@@ -80,9 +81,10 @@ myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
     [ ((modm, xK_q), io (exitWith ExitSuccess)) -- %! Quit xmonad
 
     , ((modm, xK_2), spawn "pavucontrol")
-    , ((modm, xK_3), spawn "firefox")
+    , ((modm, xK_3), spawn "firefox  -no-remote -P sfw")
+    , ((modm, xK_4), spawn "firefox")
 
-    , ((modm, xK_4), spawn "input-setup")
+    , ((modm, xK_5), spawn "input-setup")
 
     -- we would really want to keep track of which workspace is darkened,
     -- and change things depending on where that workspace is
diff --git a/subdir_files/sieve/main.sieve b/subdir_files/sieve/main.sieve
new file mode 100644 (file)
index 0000000..5fbac25
--- /dev/null
@@ -0,0 +1,24 @@
+# Sieve filter
+# note: main is just a random name, since dovecot required a name
+##
+require [ "regex", "variables", "fileinto", "envelope", "mailbox", "imap4flags", "include" ];
+
+# many examples out there check for "X-Spam-Status" "^Yes", but we do
+# this in exim, which doesn't add that by default.  We could modify it's
+# config to add $spam_action to a header, like other headers, but simply
+# using an integer threshold here is simpler: the default threshold for
+# spamassassin is 5, so we have 5 plus symbols here.
+if header :regex "x-spam_bar" "^\\+{5}" {
+    fileinto :create "Junk";
+    stop;
+}
+
+include :personal "personal";
+
+
+# note, i originally used something like this to filter mailing lists
+# http://www.dovecot.org/list/dovecot/2014-September/097846.html
+# However, I found that there were a lot of special cases
+# where I did not want them filtered, like small mailing lists, etc,
+# so I prefer to keep a list of lists that I want filed into folders.
+# However, it was useful as an example for constructing that code.