From b72b3c72d96a83791376f9d3d3832e2369b2f274 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Sun, 1 Nov 2020 20:07:31 -0500 Subject: [PATCH] bring radicale-setup into mail-setup --- brc2 | 28 ++++---- distro-end | 5 -- mail-setup | 190 ++++++++++++++++++++++++++++++++++++++----------- radicale-setup | 144 ------------------------------------- 4 files changed, 163 insertions(+), 204 deletions(-) delete mode 100755 radicale-setup diff --git a/brc2 b/brc2 index a2810f2..6d6991a 100644 --- a/brc2 +++ b/brc2 @@ -224,21 +224,7 @@ astudio() { # $ dig ns1.gnu.org @b0.org.afilias-nst.org. -bindpush() { - lipush || return 1 - for h in li; do - sl $h <<'EOF' || return 1 -set -e -source ~/.bashrc -conflink -f=/var/lib/bind/db.b8.nz -ser stop bind9 -sudo rm -fv $f.jnl -sudo install -m 644 -o bind -g bind /p/c/machine_specific/vps/bind-initial/db.b8.nz $f -ser restart bind9 -EOF - done -} +# todo: make sm pull/push use systemd instead of the journal cat command bbk() { # btrbk wrapper c / @@ -347,6 +333,18 @@ bkpush() { # no emacs. for running faster. } +bindpush() { + lipush || return 1 + for h in li bk; do + sl $h <<'EOF' || return 1 +set -e +source ~/.bashrc +dnsup +dnsb8 +EOF + done +} + dnsup() { conflink ser reload bind9 diff --git a/distro-end b/distro-end index af816c3..87e35a9 100755 --- a/distro-end +++ b/distro-end @@ -816,15 +816,10 @@ if [[ -e /p/c/gen-fsf-vpn ]]; then /p/c/gen-fsf-vpn fi -if mountpoint /o &>/dev/null; then - m /a/bin/distro-setup/radicale-setup -fi - if [[ $HOSTNAME == frodo ]]; then vpn-mk-client-cert -b frodo -n hole iankelling.org fi - ############# begin syncthing setup ########### if [[ $HOSTNAME == frodo ]]; then # It\'s simpler to just worry about running it in one place for now. diff --git a/mail-setup b/mail-setup index 046c8d9..1798fd6 100755 --- a/mail-setup +++ b/mail-setup @@ -3,11 +3,15 @@ # Copyright (C) 2019 Ian Kelling # SPDX-License-Identifier: AGPL-3.0-or-later +# todo: we should test failed mail daily or so +# failed cronjob, failed sysd-log-once, +# a local bounce from a cronjob, a local bounce +# to a bad remote address, perhaps a local failure +# when the sending daemon is down. +# And send an alert email if no alerts have been sent +# in 2 or 3 days or something. + # todo: look at mailinabox extra dns records -# -# todo: i think daemon-reload -# is being called when it shouldnt when rereunning we are probably -# updating systemd config file that doesnt need to be or something. # todo: mailtest-check failure on remote hosts is not going to alert me. # sort that out. @@ -81,10 +85,12 @@ else exit 1 fi source /a/bin/distro-functions/src/identify-distros +source /a/bin/distro-functions/src/package-manager-abstractions # has nextcloud_admin_pass in it f=/p/c/machine_specific/$HOSTNAME/mail if [[ -e $f ]]; then + # shellcheck source=/p/c/machine_specific/bk/mail source $f fi @@ -244,6 +250,11 @@ i() { # install file fi rm -rf $tmpdir } +setini() { + key="$1" value="$2" section="$3" + file="/etc/radicale/config" + sed -ri "/ *\[$section\]/,/^ *\[[^]]+\]/{/^\s*$key[[:space:]=]/d};/ *\[$section\]/a $key = $value" "$file" +} soff () { for service; do m systemctl stop $service; @@ -262,30 +273,10 @@ sstart() { m systemctl enable $service; done } -e() { printf "%s\n" "$*"; } -pi() { # package install without starting daemons - local f - if dpkg -s -- "$@" &> /dev/null; then - return 0; - fi; - while fuser /var/lib/dpkg/lock &>/dev/null; do sleep 1; done - f=/var/cache/apt/pkgcache.bin; - if [[ ! -r $f ]] || (( $(( $(date +%s) - $(stat -c %Y $f ) )) > 60*60*12 )); then - m apt-get update - fi - f=/usr/sbin/policy-rc.d - dd of=$f 2>/dev/null </dev/null; then @@ -319,7 +310,7 @@ if [[ ! $MAIL_HOST ]]; then fi -## * Install packages +# * Install universal packages if [[ $(debian-codename-compat) == bionic ]]; then cat >/etc/apt/preferences.d/spamassassin <<'EOF' @@ -355,7 +346,7 @@ fi # our nostart pi fails to avoid enabling -### * user forward file +# * user forward file case $HOSTNAME in $MAIL_HOST) # afaik, these will get ignored on MAIL_HOST because they are routing to my own @@ -485,13 +476,6 @@ case $HOSTNAME in for unit in ${nn_progs[@]}; do i /etc/systemd/system/$unit.service.d/nn.conf <<'EOF' [Unit] -JoinsNamespaceOf=mailnn.service - -[Service] -PrivateNetwork=true -EOF - i /etc/systemd/system/$unit.service.d/nn.conf <<'EOF' -[Unit] After=network.target Requires=mailvpn.service After=mailvpn.service @@ -511,7 +495,6 @@ EOF done ;; *) - reload=false for unit in exim4 spamassassin; do f=/etc/systemd/system/$unit.service.d/nn.conf if [[ -s $f ]]; then @@ -693,7 +676,7 @@ m sed -i --follow-symlinks -f - /etc/aliases </etc/exim4/conf.d/main/000_local <&2 + exit 1 + fi + + # davx/davdroid setup instructions at the bottom + + # main docs: + # http://radicale.org/user_documentation/ + # https://davdroid.bitfire.at/configuration/ + + # note on debugging: if radicale can't bind to the address, + # in the log it just says "Starting Radicale". If you run + # it in the foreground, it will give more info. Background + # plus debug does not help. + # sudo -u radicale radicale -D -f + + # created password file with: + # htpasswd -c /etc/davpass dav + + pi-nostart radicale + + i /etc/systemd/system/radicale.service.d/override.conf <&2' ERR -fi - -if ! mountpoint /o; then - echo "error /o is not a mountpoint" >&2 - exit 1 -fi - -source /a/bin/bash_unpublished/source-state -source /a/bin/distro-functions/src/package-manager-abstractions -# davx/davdroid setup instructions at the bottom - -# main docs: -# http://radicale.org/user_documentation/ -# https://davdroid.bitfire.at/configuration/ - -# note on debugging: if radicale can't bind to the address, -# in the log it just says "Starting Radicale". If you run -# it in the foreground, it will give more info. Background -# plus debug does not help. -# sudo -u radicale radicale -D -f - -# created password file with: -# htpasswd -c /etc/davpass dav - -d=/etc/systemd/system/radicale.service.d -mkdir -p $d -cat >$d/override.conf <