5 if [ ! -n "${dkim_selector}" ]; then
6 echo "Give DKIM selector argument."
10 # Set up DKIM key if necessary.
11 mkdir -p /etc/dkimkeys/
13 if [ ! -f "/etc/dkimkeys/${dkim_selector}.private" ]; then
16 dpkg -s opendkim-tools &> /dev/null
19 if [ ! "${preinstalled}" -eq "0" ]; then
20 apt install -y opendkim-tools
22 opendkim-genkey -s "${dkim_selector}"
23 mv "${dkim_selector}.private" /etc/dkimkeys/
24 if [ ! "${preinstalled}" -eq "0" ]; then
25 apt -y --purge autoremove opendkim-tools
29 # Link and adapt mail-server-specific /etc/ files.
30 ./hardlink_etc.sh mail
31 sed -i "s/REPLACE_Domain_ECALPER/$(hostname -f)/g" /etc/opendkim.conf
32 sed -i "s/REPLACE_Selector_ECALPER/${dkim_selector}/g" /etc/opendkim.conf
34 # Some useful debconf selections.
35 echo "postfix postfix/main_mailer_type string 'Internet Site'" | debconf-set-selections
36 echo "ssl_cert = </etc/letsencrypt/live/$(hostname -f)/fullchain.pem" > /etc/dovecot/conf.d/99-ssl-certs.conf
37 echo "ssl_key = </etc/letsencrypt/live/$(hostname -f)/privkey.pem" >> /etc/dovecot/conf.d/99-ssl-certs.conf
39 # The second line should not be necessary due to the first line, but for
40 # some reason the installation forgets to set up /etc/mailname early
41 # enough to not (when running newaliases) stumble over its absence.
42 echo "postfix postfix/mailname string $(hostname -f)" | debconf-set-selections
43 echo "$(hostname -f)" > /etc/mailname
45 # Everything should now be ready for installations.
46 apt install -y -o Dpkg::Options::=--force-confold postfix dovecot-imapd opendkim
47 echo "TODO: Ensure MX entry for your system in your DNS configuration."
48 echo "TODO: Ensure a proper SPF entry for this system in your DNS configuration; something like 'v=spf1 a mx -all' mapped to your host."
49 if [ "${add_dkim_record}" -eq "1" ]; then
50 echo "TODO: Add the following DKIM entry to your DNS configuration (possibly with slightly changed host entry – if your mail domain includes a subdomain, append that with a dot):"
51 cat "${dkim_selector}.txt"