X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=mail-setup;h=b97f3b929a5fd4f1f16105d9c8bcadf8c66951e5;hb=c3d175609e3366d2b9a749efa2b0ca2c3b998887;hp=31841b9ef71f6293a95e0784411fbbef44eebd48;hpb=8052829d2babeda2fc639666cf6b1ee649f283a6;p=distro-setup diff --git a/mail-setup b/mail-setup index 31841b9..b97f3b9 100755 --- a/mail-setup +++ b/mail-setup @@ -15,7 +15,8 @@ set -x # See the License for the specific language governing permissions and # limitations under the License. -# todo: make quick backups of maildir, or deliver to multiple hosts. +# TODO: copy dkim keys from within this file. its now done in conflink. +# TODO: fix dkim key to b chmod 640, group Debian-exim set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR @@ -182,7 +183,7 @@ if [[ ! -e /lib/systemd/system/openvpn-client@.service ]]; then vpn_ser=openvpn fi -if [[ $HOSTNAME == $MAIL_HOST ]]; then +if [[ $HOSTNAME == "$MAIL_HOST" ]]; then # afaik, these will get ignored because they are routing to my own # machine, but rm them is safer rm -f $(eval echo ~$u)/.forward /root/.forward @@ -317,6 +318,7 @@ EOF cat >/etc/exim4/host_local_deny_exceptions <<'EOF' mail.fsf.org +*.posteo.de EOF cat >/etc/exim4/conf.d/router/190_exim4-config_fsfsmarthost <<'EOF' @@ -339,6 +341,7 @@ EOF #### begin mail cert setup ### f=/usr/local/bin/mail-cert-cron cat >$f <<'EOF' +#!/bin/bash set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR @@ -348,7 +351,7 @@ f=/a/bin/bash_unpublished/source-state if [[ -e $f ]]; then source $f fi -if [[ $HOSTNAME == $MAIL_HOST ]]; then +if [[ $HOSTNAME == "$MAIL_HOST" ]]; then local_mx=mail.iankelling.org rsync_common="rsync -ogtL --chown=root:Debian-exim --chmod=640 root@li.iankelling.org:/etc/letsencrypt/live/$local_mx/" ${rsync_common}fullchain.pem /etc/exim4/exim.crt @@ -395,6 +398,11 @@ systemctl start mailcert systemctl restart mailcert.timer systemctl enable mailcert.timer +# This symlink is only here to so I can use the +# fsf mailman ansible role and trick its cert script +# into doing nothing. +/a/exe/lnf -T /etc/exim4/exim.crt /etc/letsencrypt/live/$(hostname -f)/fullchain.pem + ##### end mailcert setup ##### # comon stuff @@ -409,7 +417,7 @@ dc_mailname_in_oh='true' EOF -if [[ $HOSTNAME == $MAIL_HOST ]]; then +if [[ $HOSTNAME == "$MAIL_HOST" ]]; then # mail.iankelling.org so local imap clients can connect with tls and # when they happen to not be local. @@ -543,10 +551,14 @@ EOF cat >$f <<'EOF' #!/bin/bash cd /etc -wget -nv -N https://publicsuffix.org/list/public_suffix_list.dat +wget -q -N https://publicsuffix.org/list/public_suffix_list.dat EOF chmod 755 $f + sed -i --follow-symlinks -f - /etc/aliases </etc/dovecot/local.conf <<'EOF' + cat >/etc/dovecot/local.conf <>/etc/exim4/update-exim4.conf.conf < /etc/mailname + # We set this to alerts on MAIL_HOST, but using a user that doesn't exist elsewhere + # is no good. + sed -i --follow-symlinks -f - /etc/aliases </dev/null; then - chgrp 1000 /m/md/INBOX - usermod -a -G 1000 Debian-exim -else - chgrp Debian-exim /m/md/INBOX -fi -ln -s /m/md/INBOX /Maildir +sudo -u $u ln -sf -T /m/.mu /home/$u/.mu # put spool dir in directory that spans multiple distros. # based on http://www.postfix.org/qmgr.8.html and my notes in gnus @@ -865,10 +888,20 @@ systemctl restart exim4 systemctl enable exim4 -if [[ $HOSTNAME == $MAIL_HOST ]]; then - cat >/etc/cron.d/mailtest <<'EOF' -*/10 * * * * iank echo body_test | mail -s "primary_test $(date +%s) $(date +%Y-%m-%dT%H:%M:%S%z)" iank@posteo.de -2/10 * * * * root /usr/local/bin/mailtest-check +if [[ $HOSTNAME == "$MAIL_HOST" ]]; then + f=/usr/local/bin/send-test-forward + cat >$f <<'EOF' +#!/bin/bash +echo body_test | mail -s "primary_test $(date +%s) $(date +%Y-%m-%dT%H:%M:%S%z)" iank@posteo.de +EOF + chmod +x $f + + cat >/etc/cron.d/mailtest <&1 | /usr/local/bin/log-once send-test-forward +*/10 * * * * $u /usr/local/bin/mailtest-check 2>&1 | /usr/local/bin/log-once -1 send-test-forward +*/10 * * * * root chmod -R g+rw /m/md/bounces 2>&1 | /usr/local/bin/log-once -1 bounces-chmod EOF cp /a/bin/distro-setup/filesystem/usr/local/bin/mailtest-check /usr/local/bin else @@ -879,7 +912,7 @@ fi # 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 + if [[ $HOSTNAME == "$MAIL_HOST" ]]; then systemctl restart radicale systemctl enable radicale if [[ -e /etc/logrotate.d/radicale.disabled ]]; then