X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=all_new_2018%2Fsetup_scripts%2Fsetup_mail.sh;fp=all_new_2018%2Fsetup_scripts%2Fsetup_mail.sh;h=70a1342c3ac9cc738c583249111b829263c054ee;hb=83d8b23b6a489affd36458245e550e18aca41b6f;hp=ab124b92d76ef1d61f29c1e5e5caafa20732252b;hpb=5dd540eb272c50667d97c84a7100528aa1aff154;p=config diff --git a/all_new_2018/setup_scripts/setup_mail.sh b/all_new_2018/setup_scripts/setup_mail.sh index ab124b9..70a1342 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. @@ -66,8 +63,12 @@ echo "${mail_domain}" > /etc/mailname apt install -y -o Dpkg::Options::=--force-confold postfix dovecot-imapd dovecot-lmtpd dovecot-sieve opendkim 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 @@ -76,18 +77,15 @@ chown plom:plom /home/plom/.pingmailrc cp "${config_tree_prefix}/user_files/fetchmailrc" /home/plom/.fetchmailrc chown plom:plom /home/plom/.fetchmailrc chmod 0700 /home/plom/.fetchmailrc -set +e -apt install -y fetchmail + +# Pingmail and fetchmail have some systemd timers waiting. To let systemd +# know about them, do this. systemctl daemon-reload -systemctl start fetchmail.timer -set -e # 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 /home/plom/.fetchmailrc /home/plom/.pingmailrc" +echo "TODO: passwd plom for IMAPS login" +echo "TODO: adapt /home/plom/.dovecot.sieve /home/plom/.fetchmailrc /home/plom/.pingmailrc, then run: systemctl start pingmail.timer && systemctl start fetchmail.timer" +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"