+# ** exim/spool uid setup
+# i have the spool directory be common to distro multi-boot, so
+# we need the uid to be the same. 608 cuz it's kind of in the middle
+# of the free system uids.
+IFS=:; read -r _ _ uid _ < <(getent passwd Debian-exim ||:) ||:; unset IFS
+IFS=:; read -r _ _ gid _ < <(getent group Debian-exim ||:) ||:; unset IFS
+if [[ ! $uid ]]; then
+ # from /var/lib/dpkg/info/exim4-base.postinst, plus uid and gid options
+ m adduser --uid 608 --system --group --quiet --home /var/spool/exim4 \
+ --no-create-home --disabled-login --force-badname Debian-exim
+elif [[ $uid != 608 ]]; then
+ m systemctl stop exim4 ||:
+ m usermod -u 608 Debian-exim
+ m groupmod -g 608 Debian-exim
+ m usermod -g 608 Debian-exim
+ m find / /nocow -xdev -uid $uid -exec chown -h 608 {} +
+ m find / /nocow -xdev -gid $gid -exec chgrp -h 608 {} +
+fi
+
+
+
+
+# * reload exim
+
+if systemctl is-active exim4 >/dev/null; then
+ m systemctl reload exim4
+else
+ m systemctl start exim4
+fi
+
+
+# * mail monitoring / testing
+
+case $HOSTNAME in
+ $MAIL_HOST|l2)
+ # note: cronjob "ian" also does some important monitoring
+ cat >/etc/cron.d/mailtest <<EOF
+SHELL=/bin/bash
+PATH=/usr/bin:/bin:/usr/local/bin
+*/5 * * * * $u send-test-forward |& log-once send-test-forward
+*/10 * * * * root chmod -R g+rw /m/md/bounces |& log-once -1 bounces-chmod
+EOF
+ ;;&
+ $MAIL_HOST)
+ test_from=ian@iankelling.org
+ test_to=iank@posteo.de
+
+ cat >>/etc/cron.d/mailtest <<EOF
+*/5 * * * * $u mailtest-check |& log-once -1 mailtest-check
+2 * * * * $u check-remote-mailqs |& log-once check-remote-mailqs
+EOF
+ m sudo rsync -ahhi --chown=root:root --chmod=0755 \
+ /b/ds/mailtest-check /b/ds/check-remote-mailqs /usr/local/bin/
+ ;;&
+ l2)
+ test_from=iank@l2.b8.nz
+ test_to=testignore@iankelling.org
+ ;;&
+ $MAIL_HOST|l2)
+ cat >/usr/local/bin/send-test-forward <<EOFOUTER
+#!/bin/bash
+/usr/sbin/exim -t <<EOF
+From: $test_from
+To: $test_to
+Subject: primary_test \$(date +%s) \$(date +%Y-%m-%dT%H:%M:%S%z)
+
+eom
+EOF
+EOFOUTER
+ m chmod +x /usr/local/bin/send-test-forward
+ ;;
+ *)
+ rm -fv /etc/cron.d/mailtest
+ ;;
+esac
+
+
+
+# * misc
+m sudo -u $u ln -sf -T /m/.mu /home/$u/.mu
+
+
+# /etc/alias setup is debian specific, and exim postinst script sets up
+# an /etc/alias from root to the postmaster, based on the question
+# exim4-config exim4/dc_postmaster, as long as there exists an entry for
+# root, or there was no preexisting aliases file. postfix won\'t set up
+# a root to $postmaster alias if it\'s already installed. Easiest to
+# just set it ourselves.
+
+# debconf question for postmaster:
+# Mail for the 'postmaster', 'root', and other system accounts needs to be redirected
+# to the user account of the actual system administrator.
+# If this value is left empty, such mail will be saved in /var/mail/mail, which is not
+# recommended.
+# Note that postmaster\'s mail should be read on the system to which it is directed,
+# rather than being forwarded elsewhere, so (at least one of) the users listed here
+# should not redirect their mail off this machine. A 'real-' prefix can be used to
+# force local delivery.
+# Multiple user names need to be separated by spaces.
+# Root and postmaster mail recipient:
+
+
+exit 0
+: