home · contact · privacy
Add play server setup.
[config] / buster / setup_scripts / setup_mail.sh
index e65c036645ed6d82a8accdc88e9cc4d9c082b775..c749f27762c3b1118ed4fe6a9ad30d473979fd51 100755 (executable)
@@ -10,6 +10,8 @@ mail="$1"
 mail_domain="$2"
 old_server="$3"
 
+read -p'You sure you entered the correct mail domain? (not the server domain, but what comes after the @ in your mail addresses) If not, abort here!' ignore
+
 config_tree_prefix="${HOME}/config/buster"
 echo "postfix postfix/main_mailer_type string 'Internet Site'" | debconf-set-selections
 echo "postfix postfix/mailname string ${mail_domain}" | debconf-set-selections
@@ -34,12 +36,12 @@ certbot certonly --standalone --agree-tos --no-eff-email -m "${mail}" -d "$(host
 
 # For if FQDN != mail domain name.
 sed -i "s/REPLACE_maildomain_ECALPER/${mail_domain}/g" /etc/mailutils.conf
-sed -i 's/REPLACE_mail_domain_ECALPER/${mail_domain}/g' /etc/postfix/main.cf
+sed -i "s/REPLACE_maildomain_ECALPER/${mail_domain}/g" /etc/postfix/main.cf
 
 # OpenDKIM setup.
 selector=$(hostname)$(date +%Y%m%d)
 opendkim-genkey -d "${mail_domain}" -D /etc/dkimkeys -s "${selector}"
-sed -i "s/REPLACE_hostname_ECALPER/$(hostname -f)/g" /etc/opendkim.conf
+sed -i "s/REPLACE_maildomain_ECALPER/${mail_domain}/g" /etc/opendkim.conf
 sed -i "s/REPLACE_selector_ECALPER/${selector}/g" /etc/opendkim.conf
 
 # Dovecot sieve filtering via LMTP.  Without this, mail only gets
@@ -70,7 +72,6 @@ echo "plom:${password}" | chpasswd
 # Get old mail data, shutdown old postfix server.
 if [ "${old_server}" != "" ]; then
   cp "${config_tree_prefix}/setup_scripts/prepare_to_meet_server.sh" /home/plom/
-  #chown plom:plom /home/plom/prepare_to_meet_server.sh
   su -lc "./prepare_to_meet_server.sh ${old_server}" plom
   read -p'Hit Enter when you are done.' ignore
   rm /home/plom/prepare_to_meet_server.sh
@@ -78,8 +79,9 @@ if [ "${old_server}" != "" ]; then
   su -lc "scp plom@${old_server}:.fetchmailrc ~" plom
   su -lc "scp plom@${old_server}:.pingmailrc ~" plom
   su -lc "ssh -t plom@${old_server} \"su -lc 'service postfix stop'\"" plom
-  #su -lc "ssh plom@${old_server} \"su -lc 'service fetchmail_old_account stop'\"" plom
-  su -lc "ssh -t plom@${old_server} \"su -lc 'service fetchmail stop'\"" plom
+  su -lc "ssh plom@${old_server} \"su -lc 'systemctl disable fetchmail_old_account.timer'\"" plom
+  su -lc "ssh plom@${old_server} \"su -lc 'service fetchmail_old_account stop'\"" plom
+  #su -lc "ssh -t plom@${old_server} \"su -lc 'service fetchmail stop'\"" plom
   cp "${config_tree_prefix}/setup_scripts/mirror_dir.sh" /home/plom/
   su -lc "./mirror_dir.sh ${old_server} /home/plom/mail" plom
   rm /home/plom/mirror_dir.sh
@@ -97,8 +99,8 @@ service dovecot restart
 # Pingmail and fetchmail have some systemd timers waiting. To let systemd
 # know about them, do this.
 systemctl daemon-reload
-#systemctl enable --now fetchmail_old_account.timer
-#systemctl enable --now pingmail.timer
+systemctl enable --now fetchmail_old_account.timer
+systemctl enable --now pingmail.timer
 
 # Final advice to user.
 echo "To put into DNS:"
@@ -109,6 +111,7 @@ echo "Also ensure SPF record of 'v=spf1 mx -all' as TXT entry at @ or subdomain"
 echo "Also ensure reverse DNS lookup for our IP points to $(hostname -f)"
 echo "Also ensure MX record of priority 10 for @ or subdomain pointing to $(hostname -f)"
 echo "IMAPS password for user plom is: ${password}"
+echo "Also don't forget borgbackup migration …"
 
 # todo just for proper mail /sending/:
 # * how to check IP safety