From 63c4fc7fdbfd916bc2b3eeb918552db221a1f64a Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Sun, 15 Feb 2026 18:37:07 -0500 Subject: [PATCH] bunch of fixes --- brc2 | 18 +- brc3 | 2 +- distro-end | 8 +- filesystem/usr/local/bin/prof | 3 +- filesystem/usr/local/bin/prof-tail | 2 +- .../etc/systemd/system/wg-quick-tr@.service | 6 +- .../etc/systemd/system/wg-quick-tr@.service | 6 +- .../etc/systemd/system/wg-quick-tr@.service | 6 +- .../etc/systemd/system/wg-quick-tr@.service | 6 +- .../etc/systemd/system/wg-quick-tr@.service | 6 +- .../etc/systemd/system/wg-quick-tr@.service | 6 +- .../etc/systemd/system/wg-quick-tr@.service | 6 +- .../etc/systemd/system/wg-quick-tr@.service | 6 +- .../etc/systemd/system/wg-quick-tr@.service | 6 +- mail-setup | 165 ++++++------------ mailtest-check | 8 + 16 files changed, 88 insertions(+), 172 deletions(-) diff --git a/brc2 b/brc2 index ee7940d..293b50f 100644 --- a/brc2 +++ b/brc2 @@ -1185,7 +1185,7 @@ lipush() { /p/c/subdir_files/eggdrop/eggdrop-fsysbot.conf /p/c/subdir_files ) - a="-ahviSAXPH --specials --devices --delete --relative --exclude-from=/p/c/li-rsync-excludes" + a="-ahviSAXPH --specials --devices --delete --delete-excluded --relative --exclude-from=/p/c/li-rsync-excludes" ret=0 for h in li je bk; do m s rsync "$@" $a ${p[@]} /p/c/machine_specific/$h root@$h.b8.nz:/ @@ -2086,7 +2086,7 @@ host-info-all() { bindpushb8 # for wireguard configs - ssh iank@li.b8.nz "conflink; ser reload wg-quick@wgmail" + ssh iank@li.b8.nz "conflink; ser reload wg-quick-mail" wrt-setup } @@ -2227,7 +2227,7 @@ EOF local host ipsuf f files # shellcheck disable=SC2016 # shellcheck doesnt know this is sed - sedi '/edits below here are made automatically/,$d' /p/c/machine_specific/li/filesystem/etc/wireguard/wgmail.conf + sedi '/edits below here are made automatically/,$d' /p/c/machine_specific/li/filesystem/etc/wireguard/mail.conf for host in ${!vpn_ips[@]}; do if [[ ${root_hosts_a[$host]} ]]; then @@ -2247,9 +2247,8 @@ Description=Initial setup of netns for wg-quick-tr %I [Service] Type=oneshot -ExecStart=/usr/bin/flock -w 20 /tmp/newns.flock /a/bin/newns/newns -n 10.174.$ipsuf start %i -# no need to stop -#ExecStop=/usr/bin/flock -w 20 /tmp/newns.flock /a/bin/newns/newns stop %i +ExecStart=/usr/bin/flock -w 20 /tmp/newns.flock /usr/local/bin/newns/newns -n 10.174.$ipsuf start %i +ExecStop=/usr/bin/flock -w 20 /tmp/newns.flock /usr/local/bin/newns/newns stop %i RemainAfterExit=yes [Install] @@ -2261,7 +2260,6 @@ EOF Description=WireGuard via wg-quick(8) for %I After=network-online.target nss-lookup.target wg-quick-tr-pre@%i.service Wants=network-online.target nss-lookup.target wg-quick-tr-pre@%i.service -PartOf=wg-quick.target Documentation=man:wg-quick(8) Documentation=man:wg(8) @@ -2276,6 +2274,8 @@ ExecStopPost=/usr/bin/wg-quick down %i ExecStopPost=/usr/sbin/ip r del 10.8.0.0/24 via 10.174.$ipsuf.1 dev veth1-client NetworkNamespacePath=/var/run/netns/%i BindReadOnlyPaths=/etc/tr-resolv:/run/systemd/resolve:norbind /etc/basic-nsswitch:/etc/resolved-nsswitch:norbind +# copied from wg-quick@.service +Environment=WG_ENDPOINT_RESOLUTION_RETRIES=infinity [Install] WantedBy=multi-user.target @@ -2292,7 +2292,7 @@ EOF PublicKey = $(cat /p/c/machine_specific/$host/filesystem/etc/wireguard/hole-pub.key) AllowedIPs = 10.8.0.$ipsuf/32,10.174.${vpn_ips[$host]}.2/32 EOF - done | cedit /p/c/machine_specific/li/filesystem/etc/wireguard/wgmail.conf || [[ $? == 1 ]] + done | cedit /p/c/machine_specific/li/filesystem/etc/wireguard/mail.conf || [[ $? == 1 ]] { echo "cat </dev/null; do notify-cmd "$l"; done fi if (( loop_start >= EPOCH_SECONDS - 1 )); then diff --git a/machine_specific/bo/filesystem/etc/systemd/system/wg-quick-tr@.service b/machine_specific/bo/filesystem/etc/systemd/system/wg-quick-tr@.service index fb0203d..0532d94 100644 --- a/machine_specific/bo/filesystem/etc/systemd/system/wg-quick-tr@.service +++ b/machine_specific/bo/filesystem/etc/systemd/system/wg-quick-tr@.service @@ -9,17 +9,13 @@ Documentation=man:wg(8) [Service] Type=simple ExecReload=/bin/bash -c 'exec /usr/bin/wg syncconf %i <(exec /usr/bin/wg-quick strip %i)' -#ExecStartPre=/usr/bin/flock -w 20 /tmp/newns.flock /a/bin/newns/newns -n 10.174.29 start %i ExecStartPre=/sbin/iptables-restore /a/bin/distro-setup/transmission-firewall/netns.rules ExecStartPre=/usr/sbin/ip r add 10.8.0.0/24 via 10.174.29.1 dev veth1-client -# normal wg-quick has these as ExecStart and ExecStop ExecStartPre=/usr/bin/wg-quick up %i ExecStart=/bin/sleep infinity ExecStopPost=/usr/bin/wg-quick down %i ExecStopPost=/usr/sbin/ip r del 10.8.0.0/24 via 10.174.29.1 dev veth1-client -#ExecStopPost=/usr/bin/flock -w 20 /tmp/newns.flock /a/bin/newns/newns stop %i -#PrivateNetwork=true -NetworkNamespacePath=/var/run/netns/client +NetworkNamespacePath=/var/run/netns/%i BindReadOnlyPaths=/etc/tr-resolv:/run/systemd/resolve:norbind /etc/basic-nsswitch:/etc/resolved-nsswitch:norbind [Install] diff --git a/machine_specific/frodo/filesystem/etc/systemd/system/wg-quick-tr@.service b/machine_specific/frodo/filesystem/etc/systemd/system/wg-quick-tr@.service index db8187c..d6fb761 100644 --- a/machine_specific/frodo/filesystem/etc/systemd/system/wg-quick-tr@.service +++ b/machine_specific/frodo/filesystem/etc/systemd/system/wg-quick-tr@.service @@ -9,17 +9,13 @@ Documentation=man:wg(8) [Service] Type=simple ExecReload=/bin/bash -c 'exec /usr/bin/wg syncconf %i <(exec /usr/bin/wg-quick strip %i)' -#ExecStartPre=/usr/bin/flock -w 20 /tmp/newns.flock /a/bin/newns/newns -n 10.174.34 start %i ExecStartPre=/sbin/iptables-restore /a/bin/distro-setup/transmission-firewall/netns.rules ExecStartPre=/usr/sbin/ip r add 10.8.0.0/24 via 10.174.34.1 dev veth1-client -# normal wg-quick has these as ExecStart and ExecStop ExecStartPre=/usr/bin/wg-quick up %i ExecStart=/bin/sleep infinity ExecStopPost=/usr/bin/wg-quick down %i ExecStopPost=/usr/sbin/ip r del 10.8.0.0/24 via 10.174.34.1 dev veth1-client -#ExecStopPost=/usr/bin/flock -w 20 /tmp/newns.flock /a/bin/newns/newns stop %i -#PrivateNetwork=true -NetworkNamespacePath=/var/run/netns/client +NetworkNamespacePath=/var/run/netns/%i BindReadOnlyPaths=/etc/tr-resolv:/run/systemd/resolve:norbind /etc/basic-nsswitch:/etc/resolved-nsswitch:norbind [Install] diff --git a/machine_specific/kd/filesystem/etc/systemd/system/wg-quick-tr@.service b/machine_specific/kd/filesystem/etc/systemd/system/wg-quick-tr@.service index 8e56179..3f49e0a 100644 --- a/machine_specific/kd/filesystem/etc/systemd/system/wg-quick-tr@.service +++ b/machine_specific/kd/filesystem/etc/systemd/system/wg-quick-tr@.service @@ -9,17 +9,13 @@ Documentation=man:wg(8) [Service] Type=simple ExecReload=/bin/bash -c 'exec /usr/bin/wg syncconf %i <(exec /usr/bin/wg-quick strip %i)' -#ExecStartPre=/usr/bin/flock -w 20 /tmp/newns.flock /a/bin/newns/newns -n 10.174.2 start %i ExecStartPre=/sbin/iptables-restore /a/bin/distro-setup/transmission-firewall/netns.rules ExecStartPre=/usr/sbin/ip r add 10.8.0.0/24 via 10.174.2.1 dev veth1-client -# normal wg-quick has these as ExecStart and ExecStop ExecStartPre=/usr/bin/wg-quick up %i ExecStart=/bin/sleep infinity ExecStopPost=/usr/bin/wg-quick down %i ExecStopPost=/usr/sbin/ip r del 10.8.0.0/24 via 10.174.2.1 dev veth1-client -#ExecStopPost=/usr/bin/flock -w 20 /tmp/newns.flock /a/bin/newns/newns stop %i -#PrivateNetwork=true -NetworkNamespacePath=/var/run/netns/client +NetworkNamespacePath=/var/run/netns/%i BindReadOnlyPaths=/etc/tr-resolv:/run/systemd/resolve:norbind /etc/basic-nsswitch:/etc/resolved-nsswitch:norbind [Install] diff --git a/machine_specific/librestation01/filesystem/etc/systemd/system/wg-quick-tr@.service b/machine_specific/librestation01/filesystem/etc/systemd/system/wg-quick-tr@.service index 30ef28d..c1816c6 100644 --- a/machine_specific/librestation01/filesystem/etc/systemd/system/wg-quick-tr@.service +++ b/machine_specific/librestation01/filesystem/etc/systemd/system/wg-quick-tr@.service @@ -9,17 +9,13 @@ Documentation=man:wg(8) [Service] Type=simple ExecReload=/bin/bash -c 'exec /usr/bin/wg syncconf %i <(exec /usr/bin/wg-quick strip %i)' -#ExecStartPre=/usr/bin/flock -w 20 /tmp/newns.flock /a/bin/newns/newns -n 10.174.97 start %i ExecStartPre=/sbin/iptables-restore /a/bin/distro-setup/transmission-firewall/netns.rules ExecStartPre=/usr/sbin/ip r add 10.8.0.0/24 via 10.174.97.1 dev veth1-client -# normal wg-quick has these as ExecStart and ExecStop ExecStartPre=/usr/bin/wg-quick up %i ExecStart=/bin/sleep infinity ExecStopPost=/usr/bin/wg-quick down %i ExecStopPost=/usr/sbin/ip r del 10.8.0.0/24 via 10.174.97.1 dev veth1-client -#ExecStopPost=/usr/bin/flock -w 20 /tmp/newns.flock /a/bin/newns/newns stop %i -#PrivateNetwork=true -NetworkNamespacePath=/var/run/netns/client +NetworkNamespacePath=/var/run/netns/%i BindReadOnlyPaths=/etc/tr-resolv:/run/systemd/resolve:norbind /etc/basic-nsswitch:/etc/resolved-nsswitch:norbind [Install] diff --git a/machine_specific/librestation03/filesystem/etc/systemd/system/wg-quick-tr@.service b/machine_specific/librestation03/filesystem/etc/systemd/system/wg-quick-tr@.service index a4f299c..a05093e 100644 --- a/machine_specific/librestation03/filesystem/etc/systemd/system/wg-quick-tr@.service +++ b/machine_specific/librestation03/filesystem/etc/systemd/system/wg-quick-tr@.service @@ -9,17 +9,13 @@ Documentation=man:wg(8) [Service] Type=simple ExecReload=/bin/bash -c 'exec /usr/bin/wg syncconf %i <(exec /usr/bin/wg-quick strip %i)' -#ExecStartPre=/usr/bin/flock -w 20 /tmp/newns.flock /a/bin/newns/newns -n 10.174.99 start %i ExecStartPre=/sbin/iptables-restore /a/bin/distro-setup/transmission-firewall/netns.rules ExecStartPre=/usr/sbin/ip r add 10.8.0.0/24 via 10.174.99.1 dev veth1-client -# normal wg-quick has these as ExecStart and ExecStop ExecStartPre=/usr/bin/wg-quick up %i ExecStart=/bin/sleep infinity ExecStopPost=/usr/bin/wg-quick down %i ExecStopPost=/usr/sbin/ip r del 10.8.0.0/24 via 10.174.99.1 dev veth1-client -#ExecStopPost=/usr/bin/flock -w 20 /tmp/newns.flock /a/bin/newns/newns stop %i -#PrivateNetwork=true -NetworkNamespacePath=/var/run/netns/client +NetworkNamespacePath=/var/run/netns/%i BindReadOnlyPaths=/etc/tr-resolv:/run/systemd/resolve:norbind /etc/basic-nsswitch:/etc/resolved-nsswitch:norbind [Install] diff --git a/machine_specific/so/filesystem/etc/systemd/system/wg-quick-tr@.service b/machine_specific/so/filesystem/etc/systemd/system/wg-quick-tr@.service index 70c583a..3542536 100644 --- a/machine_specific/so/filesystem/etc/systemd/system/wg-quick-tr@.service +++ b/machine_specific/so/filesystem/etc/systemd/system/wg-quick-tr@.service @@ -9,17 +9,13 @@ Documentation=man:wg(8) [Service] Type=simple ExecReload=/bin/bash -c 'exec /usr/bin/wg syncconf %i <(exec /usr/bin/wg-quick strip %i)' -#ExecStartPre=/usr/bin/flock -w 20 /tmp/newns.flock /a/bin/newns/newns -n 10.174.3 start %i ExecStartPre=/sbin/iptables-restore /a/bin/distro-setup/transmission-firewall/netns.rules ExecStartPre=/usr/sbin/ip r add 10.8.0.0/24 via 10.174.3.1 dev veth1-client -# normal wg-quick has these as ExecStart and ExecStop ExecStartPre=/usr/bin/wg-quick up %i ExecStart=/bin/sleep infinity ExecStopPost=/usr/bin/wg-quick down %i ExecStopPost=/usr/sbin/ip r del 10.8.0.0/24 via 10.174.3.1 dev veth1-client -#ExecStopPost=/usr/bin/flock -w 20 /tmp/newns.flock /a/bin/newns/newns stop %i -#PrivateNetwork=true -NetworkNamespacePath=/var/run/netns/client +NetworkNamespacePath=/var/run/netns/%i BindReadOnlyPaths=/etc/tr-resolv:/run/systemd/resolve:norbind /etc/basic-nsswitch:/etc/resolved-nsswitch:norbind [Install] diff --git a/machine_specific/sy/filesystem/etc/systemd/system/wg-quick-tr@.service b/machine_specific/sy/filesystem/etc/systemd/system/wg-quick-tr@.service index 9c7b876..9902ad7 100644 --- a/machine_specific/sy/filesystem/etc/systemd/system/wg-quick-tr@.service +++ b/machine_specific/sy/filesystem/etc/systemd/system/wg-quick-tr@.service @@ -9,17 +9,13 @@ Documentation=man:wg(8) [Service] Type=simple ExecReload=/bin/bash -c 'exec /usr/bin/wg syncconf %i <(exec /usr/bin/wg-quick strip %i)' -#ExecStartPre=/usr/bin/flock -w 20 /tmp/newns.flock /a/bin/newns/newns -n 10.174.7 start %i ExecStartPre=/sbin/iptables-restore /a/bin/distro-setup/transmission-firewall/netns.rules ExecStartPre=/usr/sbin/ip r add 10.8.0.0/24 via 10.174.7.1 dev veth1-client -# normal wg-quick has these as ExecStart and ExecStop ExecStartPre=/usr/bin/wg-quick up %i ExecStart=/bin/sleep infinity ExecStopPost=/usr/bin/wg-quick down %i ExecStopPost=/usr/sbin/ip r del 10.8.0.0/24 via 10.174.7.1 dev veth1-client -#ExecStopPost=/usr/bin/flock -w 20 /tmp/newns.flock /a/bin/newns/newns stop %i -#PrivateNetwork=true -NetworkNamespacePath=/var/run/netns/client +NetworkNamespacePath=/var/run/netns/%i BindReadOnlyPaths=/etc/tr-resolv:/run/systemd/resolve:norbind /etc/basic-nsswitch:/etc/resolved-nsswitch:norbind [Install] diff --git a/machine_specific/x2/filesystem/etc/systemd/system/wg-quick-tr@.service b/machine_specific/x2/filesystem/etc/systemd/system/wg-quick-tr@.service index 64e0d95..1541fba 100644 --- a/machine_specific/x2/filesystem/etc/systemd/system/wg-quick-tr@.service +++ b/machine_specific/x2/filesystem/etc/systemd/system/wg-quick-tr@.service @@ -9,17 +9,13 @@ Documentation=man:wg(8) [Service] Type=simple ExecReload=/bin/bash -c 'exec /usr/bin/wg syncconf %i <(exec /usr/bin/wg-quick strip %i)' -#ExecStartPre=/usr/bin/flock -w 20 /tmp/newns.flock /a/bin/newns/newns -n 10.174.28 start %i ExecStartPre=/sbin/iptables-restore /a/bin/distro-setup/transmission-firewall/netns.rules ExecStartPre=/usr/sbin/ip r add 10.8.0.0/24 via 10.174.28.1 dev veth1-client -# normal wg-quick has these as ExecStart and ExecStop ExecStartPre=/usr/bin/wg-quick up %i ExecStart=/bin/sleep infinity ExecStopPost=/usr/bin/wg-quick down %i ExecStopPost=/usr/sbin/ip r del 10.8.0.0/24 via 10.174.28.1 dev veth1-client -#ExecStopPost=/usr/bin/flock -w 20 /tmp/newns.flock /a/bin/newns/newns stop %i -#PrivateNetwork=true -NetworkNamespacePath=/var/run/netns/client +NetworkNamespacePath=/var/run/netns/%i BindReadOnlyPaths=/etc/tr-resolv:/run/systemd/resolve:norbind /etc/basic-nsswitch:/etc/resolved-nsswitch:norbind [Install] diff --git a/machine_specific/x3/filesystem/etc/systemd/system/wg-quick-tr@.service b/machine_specific/x3/filesystem/etc/systemd/system/wg-quick-tr@.service index 2bf60cd..659fa17 100644 --- a/machine_specific/x3/filesystem/etc/systemd/system/wg-quick-tr@.service +++ b/machine_specific/x3/filesystem/etc/systemd/system/wg-quick-tr@.service @@ -9,17 +9,13 @@ Documentation=man:wg(8) [Service] Type=simple ExecReload=/bin/bash -c 'exec /usr/bin/wg syncconf %i <(exec /usr/bin/wg-quick strip %i)' -#ExecStartPre=/usr/bin/flock -w 20 /tmp/newns.flock /a/bin/newns/newns -n 10.174.8 start %i ExecStartPre=/sbin/iptables-restore /a/bin/distro-setup/transmission-firewall/netns.rules ExecStartPre=/usr/sbin/ip r add 10.8.0.0/24 via 10.174.8.1 dev veth1-client -# normal wg-quick has these as ExecStart and ExecStop ExecStartPre=/usr/bin/wg-quick up %i ExecStart=/bin/sleep infinity ExecStopPost=/usr/bin/wg-quick down %i ExecStopPost=/usr/sbin/ip r del 10.8.0.0/24 via 10.174.8.1 dev veth1-client -#ExecStopPost=/usr/bin/flock -w 20 /tmp/newns.flock /a/bin/newns/newns stop %i -#PrivateNetwork=true -NetworkNamespacePath=/var/run/netns/client +NetworkNamespacePath=/var/run/netns/%i BindReadOnlyPaths=/etc/tr-resolv:/run/systemd/resolve:norbind /etc/basic-nsswitch:/etc/resolved-nsswitch:norbind [Install] diff --git a/mail-setup b/mail-setup index 8ded245..c9482ad 100755 --- a/mail-setup +++ b/mail-setup @@ -749,8 +749,6 @@ EOF # and -vpnser=wg-quick@wgmail.service - case $HOSTNAME in $MAIL_HOST) rsync -aiSAX --chown=root:root --chmod=g-s /p/c/filesystem/etc/wireguard/ /etc/wireguard @@ -770,69 +768,41 @@ esac case $HOSTNAME in li) : ;; *) - u /etc/systemd/system/wg-quick@wgmail.service.d/override.conf <>/etc/exim4/conf.d/router/900_exim4-config_local_user <<'EOF' @@ -4620,6 +4565,9 @@ EOF cat >>/etc/nonn-exim4/conf.d/main/000_local <<'EOF' MAIN_HARDCODE_PRIMARY_HOSTNAME = mail2.iankelling.org EOF + # exim4in.service should do this, but it is too easy to start exim4 in the meantime. + m update-exim4.conf -d /etc/nonn-exim4 + ;; $MAIL_HOST) @@ -4650,7 +4598,6 @@ backup_redir: errors_to = alerts@iankelling.org EOF - # for bk, we have a exim4in.service that will do this for us. m update-exim4.conf -d /etc/nonn-exim4 ;; esac @@ -4904,8 +4851,8 @@ fi case $HOSTNAME in $MAIL_HOST|bk) # If any of these have config changes, then restart them as needed: - # sre mailnn mailnnroute $vpnser - son mailnn mailnnroute $vpnser + # sre wg-quick-mail + son wg-quick-mail ;;& $MAIL_HOST) # If this service's config changes, add a manual restart here. @@ -4947,7 +4894,7 @@ esac ## wip to only restart services that actually need restarting. all_units=( - mailnn.service mailnnroute.service $vpnser.service + wg-quick-mail.service unbound.service clamav-daemon.service dovecot.service $myspam_ser.service mailtest-check.service @@ -4983,7 +4930,7 @@ case $HOSTNAME in soff $spamd_ser clamav-daemon unbound ;; *) - soff radicale mailclean.timer dovecot $spamd_ser $vpnser mailnn clamav-daemon unbound + soff radicale mailclean.timer dovecot $spamd_ser wg-quick-mail clamav-daemon unbound ;; esac diff --git a/mailtest-check b/mailtest-check index f416acd..eef5e8c 100755 --- a/mailtest-check +++ b/mailtest-check @@ -34,6 +34,14 @@ #set -x +## todo: fix negative sleep: +## +##mailtest-check: end of spam debug results +# Feb 15 14:12:21 frodo mailtest-check[68446]: sleep: invalid option -- '6' +# Feb 15 14:12:21 frodo mailtest-check[68446]: Try 'sleep --help' for more information. +# Feb 15 14:12:21 frodo mailtest-check[58304]: /usr/local/bin/mailtest-check:457: `sleep $(( 300 - ( EPOCHSECONDS - premain_sec ) ))' + + [[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@" source /b/bash-bear-trap/bash-bear -- 2.30.2