-# offlineimap uses this too, it is much easier to use one location than to
-# condition it\'s config and postfix\'s config
-if [[ -f /etc/fedora-release ]]; then
- /a/exe/lnf -T ca-certificates.crt /etc/ssl/ca-bundle.trust.crt
-fi
-
-if postfix; then
- # dunno why, but debian installed postfix with builddep emacs
- # but I will just explicitly install it here since
- # I use it for sending mail in emacs.
- if command -v apt-get &> /dev/null; then
- debconf-set-selections <<EOF
-postfix postfix/main_mailer_type select Satellite system
-postfix postfix/mailname string $HOSTNAME
-postfix postfix/relayhost string $relayhost
-postfix postfix/root_address string $postmaster
-EOF
- if dpkg -s postfix &>/dev/null; then
- dpkg-reconfigure -u -fnoninteractive postfix
- else
- apt-get -y install --purge --auto-remove postfix
- fi
- else
- source /a/bin/distro-functions/src/package-manager-abstractions
- pi postfix
- # Settings from reading the output when installing on debian,
- # then seeing which were different in a default install on arch.
- # I assume the same works for fedora.
- postconfin <<EOF
-mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
-mailbox_size_limit = 0
-relayhost = $relayhost
-inet_interfaces = loopback-only
-EOF
-
- systemctl enable postfix
- systemctl start postfix
- fi
- # i\'m assuming mail just won\'t work on systems without the sasl_passwd.
- postconfin <<'EOF'
-smtp_sasl_auth_enable = yes
-smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
-smtp_sasl_security_options = noanonymous
-smtp_tls_security_level = secure
-message_size_limit = 20480000
-smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
-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
- # up and fail forever. snippet from syslog: type=AAAA: Host not found, try again
-
-
- f=/etc/postfix/sasl_passwd
- install -m 600 /dev/null $f
- cat /etc/mailpass| while read -r domain port pass; do
- # format: domain port user:pass
- # mailpass is just a name i made up, since postfix and
- # exim both use a slightly crazy format to translate to
- # each other, it\'s easier to use my own format.
- printf "[%s]:%s %s" "$domain" "$port" "${pass/@/#}" >>$f
- done
- postmap hash:/etc/postfix/sasl_passwd
- # need restart instead of reload when changing
- # inet_protocols
- service postfix restart
-
-else # begin exim. has debian specific stuff for now
-
- if ! dpkg -s openvpn &>/dev/null; then
- apt-get -y install --purge --auto-remove openvpn
- fi
-
- if [[ -e /p/c/filesystem ]]; then
- # to put the hostname in the known hosts
- ssh -o StrictHostKeyChecking=no root@li.iankelling.org :
- /a/exe/vpn-mk-client-cert -b mail -n mail li.iankelling.org
- fi
-
- cat >/etc/systemd/system/mailroute.service <<EOF
-[Unit]
-# this unit is configured to start and stop whenever $vpn_ser@mail.service
-# does
-Description=Routing for email vpn
-After=network.target
-BindsTo=$vpn_ser@mail.service
-After=$vpn_ser@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=$vpn_ser@mail.service
-EOF