X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=mail-setup;h=058fb4f52d4d56e4894212a2a1d804d4b36f4a05;hb=f7eaad64a7c5f3bc851f146e1f258d34f398a7d7;hp=c062362c18b70409db760268fc74a0ef40ea167b;hpb=c8f87d4173949b8d96c9c34e2d2c0730caeba0eb;p=distro-setup diff --git a/mail-setup b/mail-setup index c062362..058fb4f 100755 --- a/mail-setup +++ b/mail-setup @@ -50,6 +50,8 @@ EOF # hamburger -> preferences -> preferences -> advanced tab -> config editor button -> security.ssl.enable_ocsp_must_staple = false # background: ovecot does not yet have ocsp stapling support # reference: https://community.letsencrypt.org/t/simple-guide-using-lets-encrypt-ssl-certs-with-dovecot/2921 +# +# for phone, same thing but username alerts, pass in ivy-pass. ####### @@ -69,7 +71,7 @@ EOF # # dovecot password, i just need 1 as I\'m the only user # mkdir /p/c/filesystem/etc/dovecot -# echo "iank:$(doveadm pw -s ssha256)::::::" >/p/c/filesystem/etc/dovecot/users +# echo "iank:$(doveadm pw -s ssha256)::::::" >>/p/c/filesystem/etc/dovecot/users # conflink @@ -197,7 +199,7 @@ pi() { # package install apt-get -y install --purge --auto-remove "$@" } -postmaster=$u +postmaster=alerts mxhost=mail.iankelling.org mxport=587 forward=$u@$mxhost @@ -218,11 +220,11 @@ fi 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 ~$postmaster)/.forward /root/.forward + rm -f $(eval echo ~$u)/.forward /root/.forward else # this can\'t be a symlink and has permission restrictions # it might work in /etc/aliases, but this seems more proper. - install -m 644 {-o,-g}$postmaster <(e $forward) $(eval echo ~$postmaster)/.forward + install -m 644 {-o,-g}$u <(e $forward) $(eval echo ~$u)/.forward fi @@ -320,7 +322,7 @@ debconf-set-selections </etc/exim4/rcpt_local_acl <<'EOF' @@ -417,7 +419,7 @@ trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR [[ $EUID == 0 ]] || exec sudo "$BASH_SOURCE" "$@" -f=/a/bin/bash_unpublished/source-semi-priv +f=/a/bin/bash_unpublished/source-state if [[ -e $f ]]; then source $f fi @@ -474,6 +476,17 @@ systemctl enable mailcert.timer if [[ $HOSTNAME == $MAIL_HOST ]]; then + # mail.iankelling.org so local imap clients can connect with tls and + # when they happen to not be local. + sed -ri -f - /etc/hosts <<'EOF' +/^127\.0\.1\.1.* mail\.iankelling\.org\b/q +/^127\.0\.1\.1 /s/ *$/ mail.iankelling.org/ +EOF + /a/exe/cedit mail /etc/dnsmasq-servers.conf <<'EOF' || [[ $? == 1 ]] +server=/mail.iankelling.org/127.0.1.1 +EOF + systemctl reload dnsmasq + debconf-set-selections </dev/null ||: systemctl stop offlineimapsync.timer &>/dev/null ||: systemctl disable mailclean.timer &>/dev/null ||: @@ -918,17 +944,45 @@ fi dir=/nocow/exim4 sdir=/var/spool/exim4 # we only do this if our system has $dir -if [[ -e /nocow && $(readlink -f $sdir) != $dir ]]; then - systemctl stop exim4 - if [[ ! -e $dir && -d $sdir ]]; then - mv $sdir $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 + systemctl stop exim4 + if [[ -L $sdir ]]; then + rm $sdir + fi + if [[ ! -e $dir && -d $sdir ]]; then + mv $sdir $dir + fi + if [[ ! -d $sdir ]]; then + mkdir $sdir + chmod 000 $sdir # only want it to be used when its mounted + fi + mount $sdir fi - /a/exe/lnf -T $dir $sdir fi 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 +EOF + cp /a/bin/distro-setup/filesystem/usr/local/bin/mailtest-check /usr/local/bin +else + rm -f /etc/cron.d/mailtest +fi + # 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.