From: Ian Kelling Date: Tue, 23 Feb 2021 03:43:19 +0000 (-0500) Subject: fixes and extra mail backup X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=2cdeac6c56747f32dc7dc0b486d59197a72515f2;p=distro-setup fixes and extra mail backup --- diff --git a/bk-backup b/bk-backup index 4050b5b..114a015 100755 --- a/bk-backup +++ b/bk-backup @@ -5,7 +5,7 @@ shopt -s inherit_errexit 2>/dev/null ||: # ignore fail in bash < 4.4 set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?. PIPESTATUS: ${PIPESTATUS[*]}" >&2' ERR -# need root for rsync pull of file ownership/perms +# need root for rsync pull of file ownership/perms [[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@" host=bk.b8.nz diff --git a/brc b/brc index 685d6f2..9aeff8c 100644 --- a/brc +++ b/brc @@ -643,6 +643,9 @@ eqcat() { hlm exigrep $i /var/log/exim4/mainlog | cat ||: done } +eqrmf() { + exiqgrep -i | xargs exim -Mrm + } # shellcheck disable=SC2032 diff --git a/brc2 b/brc2 index ef5fb0a..52e01d8 100644 --- a/brc2 +++ b/brc2 @@ -140,6 +140,18 @@ tback() { sqlite3 /p/.timetrap.db "update entries set end = NULL where id = (select max(id) from entries);" } +bum() { + local host=$1 + (( $# == 1 )) || return 1 + sshfs $host:/bu/md /bu/mnt + ser start exim4 +} +bu() { + fusermount -u /bu/mnt +} +eqgo() { + enn -M $(exiqgrep -i) +} gnupload(){ /a/f/gnulib/build-aux/gnupload "$@" diff --git a/btrbk-run b/btrbk-run index d6de66a..9aef6e0 100644 --- a/btrbk-run +++ b/btrbk-run @@ -189,7 +189,7 @@ if [[ ! -v targets && ! $source ]]; then targets+=($home kw.office.fsf.org) ;; kd) - targets+=(x2.b8.nz) + targets+=(x2.b8.nz sy.b8.nz) # might not be connected to the vpn if timeout -s 9 6 ssh kw.office.fsf.org :; then targets+=(kw.office.fsf.org) @@ -379,13 +379,13 @@ snapshot_create onchange # I could make this different from target_preserve, # if one disk had less space. # for now, keeping them equal. -snapshot_preserve 36h 14d 8w 24m -snapshot_preserve_min 4h +snapshot_preserve 18h 14d 8w 24m +snapshot_preserve_min 2h snapshot_dir btrbk -# so, total backups = ~75 -target_preserve 36h 14d 8w 24m -target_preserve_min 4h +# so, total backups = ~58 +target_preserve 18h 14d 8w 24m +target_preserve_min 2h # if something fails and it's not obvious, try doing # btrbk -l debug -v dryrun @@ -487,6 +487,10 @@ else m /a/exe/mount-latest-remote ${targets[@]} fi +if [[ $ret == 0 ]]; then + /a/exe/mail-backup-clean +fi + mexit $ret # todo: move variable data we don't care about backing up diff --git a/check-remote-mailqs b/check-remote-mailqs index f7d00c0..8a2fc85 100755 --- a/check-remote-mailqs +++ b/check-remote-mailqs @@ -10,7 +10,7 @@ shopt -s nullglob shopt -s dotglob -for h in tp.b8.nz vpn1 x2 x3.b8.nz frodo.b8.nz kd.b8.nz kw iankelling.org bk.b8.nz; do +for h in bk.b8.nz je.b8.nz tp.b8.nz vpn1 x2 x3.b8.nz frodo.b8.nz kd.b8.nz kw iankelling.org bk.b8.nz; do if [[ $HOSTNAME == "${h%%.*}" ]]; then continue fi diff --git a/distro-begin b/distro-begin index 30ecb9b..1ad65f4 100755 --- a/distro-begin +++ b/distro-begin @@ -472,7 +472,7 @@ if encrypted; then fi ##### make extra dirs -dirs=(/mnt/{1,2,3,4,5,6,7,8,9} /nocow/t) +dirs=(/mnt/{1,2,3,4,5,6,7,8,9} /nocow/t /bu/md /bu/md/{cur,tmp,new} /bu/mnt) sudo mkdir -p "${dirs[@]}" # allow to fail because they could have read-only mounts on them sudo chown $USER:$USER "${dirs[@]}" ||: diff --git a/gitslink b/gitslink index 99ef892..a2318e0 100755 --- a/gitslink +++ b/gitslink @@ -36,8 +36,11 @@ for x in *; do done cd /a/exe +if (( ${#existing[@]} )); then + echo run manually: +fi for f in ${!existing[@]}; do - echo want to do rm -fv $f + echo rm -fv $f done diff --git a/mail-backup-clean b/mail-backup-clean new file mode 100755 index 0000000..79ffe9b --- /dev/null +++ b/mail-backup-clean @@ -0,0 +1,30 @@ +#!/bin/bash +# Copyright (C) 2016 Ian Kelling +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +if ! test "$BASH_VERSION"; then echo "error: shell is not bash" >&2; exit 1; fi +shopt -s inherit_errexit 2>/dev/null ||: # ignore fail in bash < 4.4 +set -eE -o pipefail +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" exit status: $?, PIPESTATUS: ${PIPESTATUS[*]}" >&2' ERR + +if ! mountpoint /bu/mnt &>/dev/null; then + exit 0 +fi + +cd /mnt/root/btrbk +tmp=(o*) +last_snap_date=${tmp[-1]#o.} +time=$(( $(date -d $(sed -r 's/(.{4})(..)(.{5})(..)(.*)/\1-\2-\3:\4:\5/' <<<$last_snap_date) +%s) -1 )) +# 1 second granularity, so we could have a duplicate file, oh well, not worrying about that. +find /bu/md /bu/mnt -type f \! -newermt @$time -delete diff --git a/mail-setup b/mail-setup index 9de76cf..901361c 100755 --- a/mail-setup +++ b/mail-setup @@ -3,6 +3,8 @@ # Copyright (C) 2019 Ian Kelling # SPDX-License-Identifier: AGPL-3.0-or-later +# todo: auto restart of je on checkrestart + # todo: remove old files from bk:/m/md/expertpathologyreview.com/testignore/cur # todo: run mailping test after running, or otherwise @@ -578,7 +580,7 @@ if ! grep -qFx "$line" $f; then err expected line in $f not found fi sed -i "s,^$badline$,$line," $f - m ser reload apparmor + m systemctl reload apparmor fi # note: anything added to nn_progs needs corresponding rm @@ -652,7 +654,7 @@ if $ir; then fi i /etc/spamassassin/mylocal.cf <<'EOF' -# the normal local.cf has a bunch of upstream stuff i dont want to mess with +# this is mylocal.cf because the normal local.cf has a bunch of upstream stuff i dont want to mess with # /usr/share/doc/exim4-base/README.Debian.gz: # SpamAssassin's default report should not be used in a add_header @@ -667,8 +669,6 @@ uridnsbl_skip_domain expertpathologyreview.com uridnsbl_skip_domain zroe.org EOF - - # 2020-10-19 remove old file. remove this when all hosts updated rm -fv /etc/systemd/system/spamddnsfix.{timer,service} @@ -887,13 +887,6 @@ hostlist iank_trusted = <; \\ 18.4.89.0/24 ; 2603:3005:71a:2e00::/64 ; 209.51.188.0/24 ; 2001:470:142::/48 ; 74.94.156.208/28 EOF -# This file only exists in the nn config. for bk to accept mail -# outside the nn, it needs a separate cert -cat >/etc/exim4/conf.d/main/000_local-nn <>/etc/exim4/conf.d/main/000_local-nn </etc/exim4/conf.d/main/000_local-nn <>/etc/exim4/update-exim4.conf.conf </etc/myexim4/conf.d/main/000_local-nn <<'EOF' MAIN_HARDCODE_PRIMARY_HOSTNAME = mail2.iankelling.org @@ -2337,6 +2362,9 @@ case $HOSTNAME in $MAIL_HOST|bk|je) # start spamassassin/dovecot before exim. sre dovecot spamassassin + # need to wait a bit before restarting exim, else I + # get a paniclog entry like: spam acl condition: all spamd servers failed + sleep 3 sstart mailclean.timer ;;& $MAIL_HOST) @@ -2351,7 +2379,16 @@ case $HOSTNAME in ;; esac -sre exim4 +case $HOSTNAME in + $MAIL_HOST) + # we manually mount /bu/mnt before starting + m systemctl disable exim4 + m systemctl restart exim4 + ;; + *) + sre exim4 + ;; +esac case $HOSTNAME in bk) sre exim4in ;; esac diff --git a/mailtest-check b/mailtest-check index c8f4d4d..5b7b220 100755 --- a/mailtest-check +++ b/mailtest-check @@ -85,11 +85,15 @@ for folder in ${folders[@]}; do fi declare -A results - for r in $($spamcpre spamc -y <"$latest" |sed 's/,/ /g'); do + # pyzor fails for our test message, so dont put useless load on their + # servers. + # example line that sed is parsing: + # (-0.1 / 5.0 requ) DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,SPF_HELO_PASS=-0.001,SPF_PASS=-0.001,TVD_SPACE_RATIO=0.001 autolearn=_AUTOLEARN + for r in $($spamcpre sudo -u Debian-exim spamassassin -t --cf='score PYZOR_CHECK 0' <"$latest" | tail -n2 | head -n1 | sed -r 's/^\([^)]*\) *//;s/=[^, ]*([, ]|$)/ /g'); do case $r in # we have a new domain, ignore this. # it seems like some versions of spamassassin do BODY_SINGLE_WORD, others dont, we dun care. - BODY_SINGLE_WORD|FROM_FMBLA_NEWDOM*) : ;; + BODY_SINGLE_WORD|FROM_FMBLA_NEWDOM*|autolearn) : ;; SPF_HELO_NEUTRAL) # some of my domains use neutral spf, treat them the same. results[SPF_HELO_PASS]=t diff --git a/pkgs b/pkgs index e059147..db4f7c2 100644 --- a/pkgs +++ b/pkgs @@ -91,6 +91,7 @@ p3=( elinks etckeeper evince + exim4-doc-html fakeroot fail2ban fdupes