minor fixes and improvements
[distro-setup] / mail-setup
index 6efc3e311a52c19cbf2e5f80e3cb1bcc883979c6..4ce604b0eed1011908505728dcfd71f1911ce84a 100755 (executable)
@@ -300,8 +300,7 @@ soff () {
   for service; do
     # ignore services that dont exist
     if systemctl cat $service &>/dev/null; then
-      m systemctl stop $service;
-      m systemctl disable $service
+      m systemctl disable --now $service
     fi
   done
 }
@@ -367,6 +366,10 @@ esac
 
 # * Install universal packages
 
+
+# installs epanicclean
+/a/bin/ds/install-my-scripts
+
 if [[ $(debian-codename-compat) == bionic ]]; then
   cat >/etc/apt/preferences.d/spamassassin <<'EOF'
 Package: spamassassin sa-compile spamc
@@ -464,6 +467,8 @@ EOF
 
 # old.
 #vpnser=mailvpn.service
+# todo: this hangs if it cant resolv the endpoint. we
+# want it to just retry in the background.
 vpnser=wg-quick@wgmail.service
 
 case $HOSTNAME in
@@ -474,6 +479,12 @@ case $HOSTNAME in
   bk)
     bindpaths="/etc/10.173.8.1-resolv:/etc/127.0.0.1-resolv"
     ;;&
+  *)
+    d=/p/c/machine_specific/$HOSTNAME/filesystem/etc/wireguard/
+    if [[ -d $d ]]; then
+      rsync -aiSAX --chown=root:root --chmod=g-s $d  /etc/wireguard
+    fi
+    ;;
 esac
 
 i /etc/systemd/system/wg-quick@wgmail.service.d/override.conf <<EOF
@@ -2012,7 +2023,7 @@ EOF
 
 # https://github.com/nextcloud/user_external#readme
 # plus mailinabox example
-\$CONFIG['user_backends'] = array(array('class' => 'OC_User_IMAP','arguments' => array('127.0.0.1', 143, null),),);
+#\$CONFIG['user_backends'] = array(array('class' => 'OC_User_IMAP','arguments' => array('127.0.0.1', 143, null),),);
 
 
 # based on installer check
@@ -2450,13 +2461,13 @@ EOF
 
     /a/exe/cedit nn /etc/hosts <<'EOF' || [[ $? == 1 ]]
 # note: i put nn.b8.nz into bind for good measure
-10.173.8.2 nn.b8.nz mail.iankelling.org
+10.173.8.2 nn.b8.nz mx.iankelling.org
 EOF
 
     # note: systemd-resolved will consult /etc/hosts, dnsmasq wont. this assumes
     # weve configured this file in dnsmasq if we are using it.
     /a/exe/cedit mail /etc/dnsmasq-servers.conf <<'EOF' || [[ $? == 1 ]]
-server=/mail.iankelling.org/127.0.1.1
+server=/mx.iankelling.org/127.0.1.1
 EOF
     # I used to use debconf-set-selections + dpkg-reconfigure,
     # which then updates this file
@@ -2611,11 +2622,11 @@ backup_local:
   transport = backup_maildir
 EOF
 
-
       wgholeip=$(sed -rn 's/^ *Address *= *([^/]+).*/\1/p' /etc/wireguard/wghole.conf)
       cat >>/etc/exim4/update-exim4.conf.conf <<EOF
 dc_other_hostnames='eximbackup.b8.nz'
 dc_local_interfaces='127.0.0.1;::1;$wgholeip'
+
 EOF
     else
       cat >>/etc/exim4/update-exim4.conf.conf <<EOF
@@ -2736,6 +2747,8 @@ if $reload; then
   m systemctl daemon-reload
 fi
 
+sstart epanicclean.timer
+
 case $HOSTNAME in
   je)
     /a/exe/web-conf apache2 je.b8.nz
@@ -2775,6 +2788,11 @@ case $HOSTNAME in
     fi
     if ! systemctl is-active clamav-daemon >/dev/null; then
       sstart clamav-daemon
+      out=$(rsync -aiSAX --chown=root:root --chmod=g-s /a/bin/ds/filesystem/etc/systemd/system/epanicclean.{timer,service} /etc/systemd/system)
+      if [[ $out ]]; then
+        reload=true
+      fi
+
       # note, this will cause paniclog entries because it takes like 45
       # seconds for clamav to start, i use ./epanic-clean to remove
       # them.
@@ -2858,7 +2876,11 @@ EOF
   $MAIL_HOST|bk|je)
     cat >/usr/local/bin/send-test-forward <<'EOF'
 #!/bin/bash
-exiqgrep -o 260 -i -r '^(testignore@(iankelling\.org|zroe\.org|expertpathologyreview\.com|amnimal\.ninja|je\.b8\.nz)|jtuttle@gnu\.org)$' | xargs /sbin/exim -Mrm >/dev/null
+olds=(
+/sbin/exiqgrep -o 260 -i -r '^(testignore@(iankelling\.org|zroe\.org|expertpathologyreview\.com|amnimal\.ninja|je\.b8\.nz)|jtuttle@gnu\.org)$')
+if (( ${#olds[@]} )); then
+  /sbin/exim -Mrm "${olds[@]}" >/dev/null
+fi
 EOF
     for test_from in ${test_froms[@]}; do
       cat >>/usr/local/bin/send-test-forward <<EOFOUTER