X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=mail-setup;h=33ad75a0b3af2719e63ecd3328f77070c0227605;hb=1ad20724a44a0ee3adc2f4a1d002850fbad7a372;hp=19676b2f898ac7ff962c45de98b5d24ff600e65e;hpb=d5b079d53808b65478f6f8825a8c93e7da921840;p=distro-setup diff --git a/mail-setup b/mail-setup index 19676b2..33ad75a 100755 --- a/mail-setup +++ b/mail-setup @@ -257,8 +257,54 @@ EOF # inet_protocols service postfix restart -else # exim. has debian specific stuff for now +else # begin exim. has debian specific stuff for now + if [[ -e /p/c/filesystem ]]; then + /a/exe/vpn-mk-client-cert -n mail li + fi + + cat >/etc/systemd/system/mailroute.service <<'EOF' +[Unit] +# this unit is configured to start and stop whenever openvpn-client@mail.service +# does +Description=Routing for email vpn +After=network.target +BindsTo=openvpn-client@mail.service +After=openvpn-client@mail.service + +[Service] +Type=oneshot +ExecStart=/a/bin/distro-setup/mail-route start +ExecStop=/a/bin/distro-setup/mail-route stop +RemainAfterExit=yes + +[Install] +RequiredBy=openvpn-client@mail.service +EOF + + cat >/etc/systemd/system/offlineimapsync.timer <<'EOF' +[Unit] +Description=Run offlineimap-sync once every 5 mins + +[Timer] +OnCalendar=*:0/5 + +[Install] +WantedBy=timers.target +EOF + + cat >/etc/systemd/system/offlineimapsync.service <<'EOF' +[Unit] +Description=Offlineimap sync +After=multi-user.target + +[Service] +User=ian +Type=oneshot +ExecStart=/a/bin/log-quiet/sysd-mail-once offlineimap-sync /a/bin/distro-setup/offlineimap-sync +EOF + systemctl daemon-reload + systemctl enable mailroute # wording of question from dpkg-reconfigure exim4-config # 1. internet site; mail is sent and received directly using SMTP @@ -286,6 +332,8 @@ EOF source /a/bin/bash_unpublished/source-semi-priv exim_main_dir=/etc/exim4/conf.d/main mkdir -p $exim_main_dir + + if [[ $HOSTNAME == $MAIL_HOST ]]; then debconf-set-selections </etc/systemd/system/offlineimapsync.timer <<'EOF' -[Unit] -Description=Run offlineimap-sync once every 5 mins - -[Timer] -OnCalendar=*:0/5 - -[Install] -WantedBy=timers.target -EOF - - cat >/etc/systemd/system/offlineimapsync.service <<'EOF' -[Unit] -Description=Offlineimap sync -After=multi-user.target - -[Service] -User=ian -Type=oneshot -ExecStart=/a/bin/log-quiet/sysd-mail-once offlineimap-sync /a/bin/distro-setup/offlineimap-sync -EOF - systemctl daemon-reload systemctl enable offlineimapsync.timer systemctl start offlineimapsync.timer + systemctl restart openvpn-client@mail + systemctl enable openvpn-client@mail else # $HOSTNAME != $MAIL_HOST systemctl disable offlineimapsync.timer &>/dev/null ||: systemctl stop offlineimapsync.timer &>/dev/null ||: + systemctl disable openvpn-client@mail + systemctl stop openvpn-client@mail # # # would only exist because I wrote it i the previous condition, @@ -471,6 +501,7 @@ EOF exim4-config exim4/dc_eximconfig_configtype select mail sent by smarthost; no local mail exim4-config exim4/dc_smarthost string $smarthost EOF + fi # end $HOSTNAME != $MAIL_HOST # if we already have it installed, need to reconfigure, without being prompted @@ -494,6 +525,7 @@ EOF # just noticed this in the config file, seems like a good idea. sed -i '/^\s*NICE\s*=/d' /etc/default/spamassassin e 'NICE="--nicelevel 15"' >>/etc/default/spamassassin + systemctl start spamassassin systemctl reload spamassassin cat >/etc/systemd/system/spamddnsfix.service <<'EOF' @@ -734,6 +766,7 @@ EOF # begin setup passwd.client f=/etc/exim4/passwd.client + rm -f /etc/exim4/passwd.client install -m 640 -g Debian-exim /dev/null $f cat /etc/mailpass| while read -r domain port pass; do # reference: exim4_passwd_client(5) @@ -767,6 +800,9 @@ 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