home
·
contact
·
privacy
projects
/
config
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Change default mail server domain.
[config]
/
buster
/
setup_scripts
/
setup_mail.sh
diff --git
a/buster/setup_scripts/setup_mail.sh
b/buster/setup_scripts/setup_mail.sh
index b58492107b892b21ade837272dd5632d0d2ae8d6..e65c036645ed6d82a8accdc88e9cc4d9c082b775 100755
(executable)
--- a/
buster/setup_scripts/setup_mail.sh
+++ b/
buster/setup_scripts/setup_mail.sh
@@
-3,15
+3,16
@@
set -e
# Check we have the necessary arguments.
if [ "$#" -lt 1 ]; then
# Check we have the necessary arguments.
if [ "$#" -lt 1 ]; then
- echo 'Need mail for letsencrypt
(and optionally old server IP)
.'
+ echo 'Need mail for letsencrypt
, mail domain, and optionally old server IP
.'
false
fi
mail="$1"
false
fi
mail="$1"
-old_server="$2"
+mail_domain="$2"
+old_server="$3"
config_tree_prefix="${HOME}/config/buster"
echo "postfix postfix/main_mailer_type string 'Internet Site'" | debconf-set-selections
config_tree_prefix="${HOME}/config/buster"
echo "postfix postfix/main_mailer_type string 'Internet Site'" | debconf-set-selections
-echo "postfix postfix/mailname string $
(hostname -f)
" | debconf-set-selections
+echo "postfix postfix/mailname string $
{mail_domain}
" | debconf-set-selections
./install_for_target.sh mail
./copy_dirtree.sh "${config_tree_prefix}/etc_files" "" mail
nft -f /etc/nftables.conf
./install_for_target.sh mail
./copy_dirtree.sh "${config_tree_prefix}/etc_files" "" mail
nft -f /etc/nftables.conf
@@
-31,9
+32,13
@@
cat "${config_tree_prefix}/other_files/append_opendkim.conf" >> /etc/opendkim.co
# TODO: Is it auto-renewed?
certbot certonly --standalone --agree-tos --no-eff-email -m "${mail}" -d "$(hostname -f)"
# TODO: Is it auto-renewed?
certbot certonly --standalone --agree-tos --no-eff-email -m "${mail}" -d "$(hostname -f)"
+# 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
+
# OpenDKIM setup.
selector=$(hostname)$(date +%Y%m%d)
# OpenDKIM setup.
selector=$(hostname)$(date +%Y%m%d)
-opendkim-genkey -d "$
(hostname -f)
" -D /etc/dkimkeys -s "${selector}"
+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_selector_ECALPER/${selector}/g" /etc/opendkim.conf
sed -i "s/REPLACE_hostname_ECALPER/$(hostname -f)/g" /etc/opendkim.conf
sed -i "s/REPLACE_selector_ECALPER/${selector}/g" /etc/opendkim.conf
@@
-56,12
+61,6
@@
cp "${config_tree_prefix}/other_files/pingmailrc" /home/plom/.pingmailrc
chown plom:plom /home/plom/.pingmailrc
su -lc "cd && git clone https://plomlompom.com/repos/clone/pingmail" plom
chown plom:plom /home/plom/.pingmailrc
su -lc "cd && git clone https://plomlompom.com/repos/clone/pingmail" plom
-# 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
-
# To allow IMAPS access.
echo "ssl_cert = </etc/letsencrypt/live/$(hostname -f)/fullchain.pem" > /etc/dovecot/conf.d/99-ssl-certs.conf
echo "ssl_key = </etc/letsencrypt/live/$(hostname -f)/privkey.pem" >> /etc/dovecot/conf.d/99-ssl-certs.conf
# To allow IMAPS access.
echo "ssl_cert = </etc/letsencrypt/live/$(hostname -f)/fullchain.pem" > /etc/dovecot/conf.d/99-ssl-certs.conf
echo "ssl_key = </etc/letsencrypt/live/$(hostname -f)/privkey.pem" >> /etc/dovecot/conf.d/99-ssl-certs.conf
@@
-78,7
+77,9
@@
if [ "${old_server}" != "" ]; then
su -lc "scp plom@${old_server}:.dovecot.sieve ~" plom
su -lc "scp plom@${old_server}:.fetchmailrc ~" plom
su -lc "scp plom@${old_server}:.pingmailrc ~" plom
su -lc "scp plom@${old_server}:.dovecot.sieve ~" plom
su -lc "scp plom@${old_server}:.fetchmailrc ~" plom
su -lc "scp plom@${old_server}:.pingmailrc ~" plom
- su -lc "ssh plom@${old_server} \"su -lc 'service postfix stop'\"" 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
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
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
@@
-93,6
+94,12
@@
service opendkim restart
service postfix restart
service dovecot restart
service postfix restart
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
+
# Final advice to user.
echo "To put into DNS:"
cat "/etc/dkimkeys/${selector}.txt"
# Final advice to user.
echo "To put into DNS:"
cat "/etc/dkimkeys/${selector}.txt"
@@
-103,9
+110,6
@@
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 ensure MX record of priority 10 for @ or subdomain pointing to $(hostname -f)"
echo "IMAPS password for user plom is: ${password}"
-# TODO:
-# - mailutils.conf from old config for pingmail?
-
# todo just for proper mail /sending/:
# * how to check IP safety
# https://talosintelligence.com/reputation_center/lookup?search=$IP
# todo just for proper mail /sending/:
# * how to check IP safety
# https://talosintelligence.com/reputation_center/lookup?search=$IP