From: Christian Heller Date: Sun, 16 Dec 2018 01:03:46 +0000 (+0100) Subject: Fix mail server setup script. X-Git-Url: https://plomlompom.com/repos/?p=config;a=commitdiff_plain;h=67f74adea42ed093787c287342217c8f8bc9c878 Fix mail server setup script. --- diff --git a/all_new_2018/setup_scripts/setup_mail.sh b/all_new_2018/setup_scripts/setup_mail.sh index 7b256b7..ab124b9 100755 --- a/all_new_2018/setup_scripts/setup_mail.sh +++ b/all_new_2018/setup_scripts/setup_mail.sh @@ -66,16 +66,21 @@ 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 +cp "${config_tree_prefix}/user_files/pingmailrc" /home/plom/.pingmailrc +chown plom:plom /home/plom/.pingmailrc # 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 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 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." @@ -85,4 +90,4 @@ if [ "${add_dkim_record}" -eq "1" ]; then cat "${dkim_selector}.txt" fi echo "TODO: passwd plom" -echo "TODO: adapt /home/plom/.dovecot.sieve and /home/plom/.fetchmailrc" +echo "TODO: adapt /home/plom/.dovecot.sieve /home/plom/.fetchmailrc /home/plom/.pingmailrc" diff --git a/all_new_2018/user_files/fetchmailrc b/all_new_2018/user_files/fetchmailrc old mode 100644 new mode 100755 diff --git a/all_new_2018/user_files/pingmailrc b/all_new_2018/user_files/pingmailrc new file mode 100644 index 0000000..46bcbfe --- /dev/null +++ b/all_new_2018/user_files/pingmailrc @@ -0,0 +1,45 @@ +# place for test files whose modification times are used to track lifesigns +testdir=$HOME'/.pingmail' + +# modification time is the last time a ping was sent or a lifetime received +ping_touch=$testdir'/ping_touch' + +# modification time is when the count for sending checker a warning mail starts +reminder_touch=$testdir'/reminder_touch' + +# how long to wait for lifesigns before sending a ping; double is time to wait +# for a lifesign before sending a warning message to checker +wait_time=86400 + +# address of the checker, receives warning message after too long wait +checker_address='bar@example.org' + +# address of the checked person, ping is sent here +checked_address='foo@example.org' + +# content of ping message sent to checked person +subj2checked='[pingmail] Ping!' +msg2checked='Hi!\n +\nThis is an automated mail ping from '$checker_address'. +\nRespond to show that you are still alive!' + +# content of warning message sent to checker +id_target='foo' +subj2checker='[pingmail] No recent life signs from '$id_target +reminder_time=`expr $wait_time \* 2` +msg2checker='pingmail reporting in:\n +\nNo life signs from '$id_target' for the last '$reminder_time' seconds. +\nMaybe you should give them a call to check if they are okay.' + +# mail client command reading message body from stdin and subject from parameter +mailclient_s='mail -s' + +# mailbox file to check for most recent life sign +mbox=$HOME'/mail/foo' + +# to recursively search for most recent matches to $matchstring as lifesigns +#maildir=$HOME'/mail' + +# pattern to search $maildir for recursively for lifesigns +#checked_address_escaped=`echo $checked_address | sed 's/\./\\./g'` +#matchstring='^From: .*('$checked_address_escaped'|alternate@example\.org)'