From: Ian Kelling Date: Thu, 30 Mar 2017 23:27:47 +0000 (-0700) Subject: various fixes and improvements, several email stuff X-Git-Url: https://iankelling.org/git/?p=distro-setup;a=commitdiff_plain;h=c1380ecb6d9f7206fcb88fc01d584143146c6a1e various fixes and improvements, several email stuff --- diff --git a/.dovecot.sieve b/.dovecot.sieve deleted file mode 100644 index fb852bc..0000000 --- a/.dovecot.sieve +++ /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*&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 + e btrfs scrub start -Bd $mnt done diff --git a/filesystem/etc/dovecot/conf.d/20-lmtp.conf b/filesystem/etc/dovecot/conf.d/20-lmtp.conf index 0955b17..43acd1d 100644 --- a/filesystem/etc/dovecot/conf.d/20-lmtp.conf +++ b/filesystem/etc/dovecot/conf.d/20-lmtp.conf @@ -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 } diff --git a/filesystem/etc/dovecot/local.conf b/filesystem/etc/dovecot/local.conf index 95536f2..8303380 100644 --- a/filesystem/etc/dovecot/local.conf +++ b/filesystem/etc/dovecot/local.conf @@ -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 index 0000000..bfdcf29 --- /dev/null +++ b/filesystem/etc/exim4/conf.d/router/900_exim4-config_local_user @@ -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 index eb5121c..0000000 --- a/filesystem/etc/exim4/conf.d/router/950_exim4-config_local_catchall +++ /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 index 0000000..ed621d6 --- /dev/null +++ b/filesystem/etc/profile.d/environment.sh @@ -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 index 0000000..dcfba45 --- /dev/null +++ b/filesystem/etc/systemd/system.conf.d/tz.conf @@ -0,0 +1,3 @@ +[Manager] +DefaultEnvironment=TZ=:/etc/localtime +# also set in profile.d/environment.sh with explanation there diff --git a/subdir_files/.xmonad/xmonad.hs b/subdir_files/.xmonad/xmonad.hs index 9ab7bec..6a0bd5a 100644 --- a/subdir_files/.xmonad/xmonad.hs +++ b/subdir_files/.xmonad/xmonad.hs @@ -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 index 0000000..5fbac25 --- /dev/null +++ b/subdir_files/sieve/main.sieve @@ -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.