X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=all_new_2018%2Fsetup_scripts%2Fsetup_mail.sh;h=208070524e40916861f13610284c320678216f52;hb=710b6e4e7337b99a79910d35ef8216d214355719;hp=7b256b7c66943a403a564982fcadc06c1ca32646;hpb=e8da7564122f157748e9a8f62e9066123d9d63ad;p=config diff --git a/all_new_2018/setup_scripts/setup_mail.sh b/all_new_2018/setup_scripts/setup_mail.sh index 7b256b7..2080705 100755 --- a/all_new_2018/setup_scripts/setup_mail.sh +++ b/all_new_2018/setup_scripts/setup_mail.sh @@ -1,6 +1,7 @@ #/bin/sh set -e +# Check we have the necessary arguments. if [ $# -lt 2 ]; then echo "Give arguments of mail domain and DKIM selector." echo "Also, if hosting mail for entire domain, give third argument 'domainwide'." @@ -14,23 +15,19 @@ config_tree_prefix="${HOME}/config/all_new_2018" setup_scripts_dir="${config_tree_prefix}/setup_scripts" cd "${setup_scripts_dir}" -# Set up DKIM key if necessary. +# Set up DKIM key. Only keep opendkim-tools on system if pre-installed. mkdir -p /etc/dkimkeys/ -add_dkim_record=0 -if [ ! -f "/etc/dkimkeys/${dkim_selector}.private" ]; then - add_dkim_record=1 - set +e - dpkg -s opendkim-tools &> /dev/null - preinstalled="$?" - set -e - if [ ! "${preinstalled}" -eq "0" ]; then - apt install -y opendkim-tools - fi - opendkim-genkey -s "${dkim_selector}" - mv "${dkim_selector}.private" /etc/dkimkeys/ - if [ ! "${preinstalled}" -eq "0" ]; then - apt -y --purge autoremove opendkim-tools - fi +set +e +dpkg -s opendkim-tools &> /dev/null +preinstalled="$?" +set -e +if [ ! "${preinstalled}" -eq "0" ]; then + apt install -y opendkim-tools +fi +opendkim-genkey -s "${dkim_selector}" +mv "${dkim_selector}.private" /etc/dkimkeys/ +if [ ! "${preinstalled}" -eq "0" ]; then + apt -y --purge autoremove opendkim-tools fi # Link and adapt mail-server-specific /etc/ files. @@ -67,22 +64,31 @@ apt install -y -o Dpkg::Options::=--force-confold postfix dovecot-imapd dovecot- cp "${config_tree_prefix}/user_files/dovecot.sieve" /home/plom/.dovecot.sieve chown plom:plom /home/plom/.dovecot.sieve +# Pingmail setup. +apt install -y mailutils +cp "${config_tree_prefix}/user_files/pingmailrc" /home/plom/.pingmailrc +chown plom:plom /home/plom/.pingmailrc +su plom -c "cd && git clone https://plomlompom.com/repos/clone/pingmail.git" + # In addition to our postfix server receiving mails, we funnel mails from a # POP3 account into dovecot via fetchmail. It might make sense to adapt the # ~/.dovecot.sieve to move mails targeted to the fetched mail account to their # own mbox. -apt install -y fetchmail +apt -y install fetchmail cp "${config_tree_prefix}/user_files/fetchmailrc" /home/plom/.fetchmailrc chown plom:plom /home/plom/.fetchmailrc +chmod 0700 /home/plom/.fetchmailrc + +# Pingmail and fetchmail have some systemd timers waiting. To let systemd +# know about them, do this. systemctl daemon-reload -systemctl start fetchmail.timer # Final advice to user. echo "TODO: Ensure MX entry for your system in your DNS configuration." echo "TODO: Ensure a proper SPF entry for this system in your DNS configuration; something like 'v=spf1 mx -all' mapped to your host." -if [ "${add_dkim_record}" -eq "1" ]; then - 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):" - cat "${dkim_selector}.txt" -fi -echo "TODO: passwd plom" -echo "TODO: adapt /home/plom/.dovecot.sieve and /home/plom/.fetchmailrc" +echo "TODO: passwd plom for IMAPS login" +echo "TODO: adapt /home/plom/.fetchmailrc and then do: systemctl start fetchmail.timer" +echo "TODO: adapt /home/plom/.dovecot.sieve and /home/plom/.pingmailrc (sieve mail by pingmail target person into mbox defined in .pingmailrc), then run: systemctl start pingmail.timer" +echo "TODO: Add the follow DMARK entry as TXT to your DNS configugration: 'v=DMARC1; p=none; rua=mailto:plom+dmarc@plomlompom.com;' mapped to _dmarc" +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):" +cat "${dkim_selector}.txt"