- newaliases
- fi
-
- # put spool dir in directory that spans multiple distros.
- # based on http://www.postfix.org/qmgr.8.html and my notes in gnus
- #
- # todo: I\'m suspicious of uids for Debian-exim being the same across
- # distros. It would be good to test this.
- dir=/nocow/$type
- sdir=/var/spool/$type
- # we only do this if our system has $dir
- if [[ -e /nocow && $(readlink -f $sdir) != $dir ]]; then
- systemctl stop $type
- if [[ ! -e $dir && -d $sdir ]]; then
- mv $sdir $dir
- fi
- /a/exe/lnf -T $dir $sdir
- fi
-
- systemctl restart $type
- systemctl enable $type
-
- # MAIL_HOST also does radicale, and easier to start and stop it here
- # for when MAIL_HOST changes, so radicale gets the synced files and
- # does not stop us from remounting /o.
- if dpkg -s radicale &>/dev/null; then
- if [[ $HOSTNAME == $MAIL_HOST ]]; then
- systemctl restart radicale
- systemctl enable radicale
- if [[ -e /etc/logrotate.d/radicale.disabled ]]; then
- mv /etc/logrotate.d/radicale{.disabled,}
- fi
- else
- systemctl stop radicale
- systemctl disable radicale
- # weekly logrotate tries to restart radicale even if it's a disabled service in flidas.
- if [[ -e /etc/logrotate.d/radicale ]]; then
- mv /etc/logrotate.d/radicale{,.disabled}
- fi
- fi
- fi
- exit 0
-
- # if I wanted the from address to be renamed and sent to a different address,
- # echo "sdx@localhost development@localhost" | sudo dd of=/etc/postfix/recipient_canonical
- # sudo postmap hash:/etc/postfix/recipient_canonical
- # sudo service postfix reload
+
+fi # end $HOSTNAME != $MAIL_HOST
+
+# * spool dir setup
+
+# ** bind mount setup
+# put spool dir in directory that spans multiple distros.
+# based on http://www.postfix.org/qmgr.8.html and my notes in gnus
+#
+# todo: I\'m suspicious of uids for Debian-exim being the same across
+# distros. It would be good to test this.
+dir=/nocow/exim4
+sdir=/var/spool/exim4
+# we only do this if our system has $dir
+
+# this used to do a symlink, but, in the boot logs, /nocow would get mounted succesfully,
+# about 2 seconds later, exim starts, and immediately puts into paniclog:
+# honVi-0000u3-82 Failed to create directory "/var/spool/exim4/input": No such file or directory
+# so, im trying a bind mount to get rid of that.
+if [[ -e /nocow ]]; then
+ if ! grep -Fx "/nocow/exim4 /var/spool/exim4 none bind 0 0" /etc/fstab; then
+ echo "/nocow/exim4 /var/spool/exim4 none bind 0 0" >>/etc/fstab
+ fi
+ if ! mountpoint -q $sdir; then
+ m systemctl stop exim4
+ if [[ -L $sdir ]]; then
+ m rm $sdir
+ fi
+ if [[ ! -e $dir && -d $sdir ]]; then
+ m mv $sdir $dir
+ fi
+ if [[ ! -d $sdir ]]; then
+ m mkdir $sdir
+ m chmod 000 $sdir # only want it to be used when its mounted
+ fi
+ m mount $sdir
+ fi
+fi
+
+
+
+# ** 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 _ _ uid _ < <(getent passwd Debian-exim ||:) ||:; unset IFS
+IFS=:; read _ _ 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
+if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
+ f=/usr/local/bin/send-test-forward
+ cat >$f <<'EOFOUTER'
+#!/bin/bash
+/usr/sbin/exim -t <<EOF
+From: ian@iankelling.org
+To: iank@posteo.de
+Subject: primary_test $(date +%s) $(date +%Y-%m-%dT%H:%M:%S%z)
+
+eom
+EOF
+EOFOUTER
+ m chmod +x $f
+
+ cat >/etc/cron.d/mailtest <<EOF
+SHELL=/bin/bash
+# running as user just because no need to run as root
+*/10 * * * * $u $f 2>&1 | /usr/local/bin/log-once send-test-forward
+*/10 * * * * $u /usr/local/bin/mailtest-check 2>&1 | /usr/local/bin/log-once -1 mailtest-check
+*/10 * * * * root chmod -R g+rw /m/md/bounces 2>&1 | /usr/local/bin/log-once -1 bounces-chmod
+EOF
+ m cp /a/bin/distro-setup/filesystem/usr/local/bin/mailtest-check /usr/local/bin
+else
+ rm -fv /etc/cron.d/mailtest
+fi
+
+
+# * Radicale
+
+# MAIL_HOST also does radicale, and easier to start and stop it here
+# for when MAIL_HOST changes, so radicale gets the synced files and
+# does not stop us from remounting /o.
+if dpkg -s radicale &>/dev/null; then
+ if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
+ m systemctl restart radicale
+ m systemctl enable radicale
+ if [[ -e /etc/logrotate.d/radicale.disabled ]]; then
+ m mv /etc/logrotate.d/radicale{.disabled,}
+ fi
+ else
+ m systemctl stop radicale
+ m systemctl disable radicale
+ # weekly logrotate tries to restart radicale even if it's a disabled service in flidas.
+ if [[ -e /etc/logrotate.d/radicale ]]; then
+ m mv /etc/logrotate.d/radicale{,.disabled}
+ fi
+ fi
+fi
+
+# * 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
+: