#!/bin/bash
+set -x
+
# Copyright (C) 2016 Ian Kelling
# Licensed under the Apache License, Version 2.0 (the "License");
# # host -t txt _dmarc.gmail.com
# # yahoo: p=reject, hotmail: p=none, gmail: p=none, fastmail none for legacy reasons
# # there were articles claiming gmail would be changing
-# # to p=reject, in early 2017, which didn't happen. I see no sources on them. It's
+# # to p=reject, in early 2017, which didn\'t happen. I see no sources on them. It\'s
# # expected to cause problems
# # with a few old mailing lists, copying theirs for now.
#
inet_protocols = ipv4
EOF
# msg_size_limit: I ran into a log file not sending cuz of size. double from 10 to 20 meg limit
- # inet_protocols: without this, I've had postfix try an ipv6 lookup then gives
+ # inet_protocols: without this, I\'ve had postfix try an ipv6 lookup then gives
# up and fail forever. snippet from syslog: type=AAAA: Host not found, try again
mkdir -p $exim_main_dir
+
+ #### begin mail cert setup ###
+ f=/usr/local/bin/mail-cert-cron
+ cat >$f <<'EOF'
+set -eE -o pipefail
+trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
+
+[[ $EUID == 0 ]] || exec sudo "$BASH_SOURCE" "$@"
+
+f=/a/bin/bash_unpublished/source-semi-priv
+if [[ -e $f ]]; then
+ source $f
+fi
+if [[ $HOSTNAME == $MAIL_HOST ]]; then
+ local_mx=mail.iankelling.org
+ rsync_common="rsync -ogtL --chown=root:Debian-exim --chmod=640 root@li:/etc/letsencrypt/live/$local_mx/"
+ ${rsync_common}fullchain.pem /etc/exim4/exim.crt
+ ${rsync_common}privkey.pem /etc/exim4/exim.key
+fi
+EOF
+ chmod 755 $f
+
+ cat >/etc/systemd/system/mailcert.service <<'EOF'
+[Unit]
+Description=Mail cert rsync
+After=multi-user.target
+
+[Service]
+Type=oneshot
+ExecStart=/a/bin/log-quiet/sysd-mail-once mailcert /usr/local/bin/mail-cert-cron
+EOF
+
+ cat >/etc/systemd/system/mailcert.timer <<'EOF'
+[Unit]
+Description=Run mail-cert once a day
+
+[Timer]
+OnCalendar=daily
+
+[Install]
+WantedBy=timers.target
+EOF
+ systemctl daemon-reload
+ systemctl start mailcert
+ systemctl restart mailcert.timer
+ systemctl enable mailcert.timer
+
+ ##### end mailcert setup #####
+
+
+
if [[ $HOSTNAME == $MAIL_HOST ]]; then
debconf-set-selections <<EOF
/^\s*mail_location\s*=/d
EOF
- cat >/etc/dovecot/conf.d/20-lmtp.conf <<'EOF'
+ cat >/etc/dovecot/conf.d/20-lmtp.conf <<EOF
protocol lmtp {
#per https://wiki2.dovecot.org/Pigeonhole/Sieve/Configuration
- mail_plugins = $mail_plugins sieve
+ mail_plugins = \$mail_plugins sieve
# default was
- #mail_plugins = $mail_plugins
+ #mail_plugins = \$mail_plugins
# For a normal setup with exim, we need something like this, which
# removes the domain part
# A normal way to do this, which I did at first is to have
# a router in exim almost at the end, eg 950,
#local_catchall:
-# debug_print = "R: catchall for $local_part@$domain"
+# debug_print = "R: catchall for \$local_part@\$domain"
# driver = redirect
# domains = +local_domains
-# data = ian
+# data = $u
# based on
# http://blog.alteholz.eu/2015/04/exim4-and-catchall-email-address/
# with superflous options removed.
# which makes filtering into mailboxes a little less robust or more complicated,
# so I've done it this way instead. it also requires
# modifying the local router in exim.
- auth_username_format = ian
+ auth_username_format = $u
}
EOF
ExecStart=/a/bin/distro-setup/spamd-dns-fix
EOF
# 2017-09, debian closed the bug on this saying upstream had fixed it.
- # remove this when i'm using the newer package, ie, debian 10, or maybe
+ # remove this when i\'m using the newer package, ie, debian 10, or maybe
# ubuntu 18.04.
cat >/etc/systemd/system/spamddnsfix.timer <<'EOF'
[Unit]
##### end spamassassin config
- f=/usr/local/bin/mail-cert-cron
- cat >$f <<'EOF'
-set -eE -o pipefail
-trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
-
-[[ $EUID == 0 ]] || exec sudo "$BASH_SOURCE" "$@"
-
-f=/a/bin/bash_unpublished/source-semi-priv
-if [[ -e $f ]]; then
- source $f
-fi
-if [[ $HOSTNAME == $MAIL_HOST ]]; then
- local_mx=mail.iankelling.org
- rsync_common="rsync -ogtL --chown=root:Debian-exim --chmod=640 root@li:/etc/letsencrypt/live/$local_mx/"
- ${rsync_common}fullchain.pem /etc/exim4/exim.crt
- ${rsync_common}privkey.pem /etc/exim4/exim.key
-fi
-EOF
- chmod 755 $f
-
- cat >/etc/systemd/system/mailcert.service <<'EOF'
-[Unit]
-Description=Mail cert rsync
-After=multi-user.target
-
-[Service]
-Type=oneshot
-ExecStart=/a/bin/log-quiet/sysd-mail-once mailcert /usr/local/bin/mail-cert-cron
-EOF
-
- cat >/etc/systemd/system/mailcert.timer <<'EOF'
-[Unit]
-Description=Run mail-cert once a day
-
-[Timer]
-OnCalendar=daily
-
-[Install]
-WantedBy=timers.target
-EOF
- systemctl daemon-reload
- systemctl start mailcert
- systemctl restart mailcert.timer
- systemctl enable mailcert.timer
-
-
-
sed -r s/^\\S+:/$b:/ 600_exim4-config_userforward >175_$b
systemctl restart exim4
- fi # end if exim4
+fi #### end if exim4
- # /etc/alias setup is debian specific, and
- # exim config sets up an /etc/alias from root to the postmaster, which i
- # config to ian, as long as there exists an entry for root, or there was
- # no preexisting aliases file. based on the postinst file. postfix
- # won't set up a root to $postmaster alias if it's already installed.
- # Since postfix is not the greatest, just set it ourselves.
- if [[ $postmaster != root ]]; then
- sed -i --follow-symlinks -f - /etc/aliases <<EOF
+# /etc/alias setup is debian specific, and
+# exim config sets up an /etc/alias from root to the postmaster, which i
+# config to ian, as long as there exists an entry for root, or there was
+# no preexisting aliases file. based on the postinst file. postfix
+# won\'t set up a root to $postmaster alias if it\'s already installed.
+# Since postfix is not the greatest, just set it ourselves.
+if [[ $postmaster != root ]]; then
+ sed -i --follow-symlinks -f - /etc/aliases <<EOF
\$a root: $postmaster
/^root:/d
EOF
- newaliases
- fi
+ 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
+# 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