From f28d189d4a5de49cd23f785046dd2547d8e7450f Mon Sep 17 00:00:00 2001 From: Christoph Date: Wed, 28 Dec 2022 18:30:17 +0100 Subject: [PATCH] install_postfix_base.sh, install_postfix_advanced.sh: support for setting up cronjobs.. --- install_postfix_advanced.sh | 43 +++++++++++++++++++++++++++++++++++++ install_postfix_base.sh | 42 ++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) diff --git a/install_postfix_advanced.sh b/install_postfix_advanced.sh index 996f1fa..8bd129c 100755 --- a/install_postfix_advanced.sh +++ b/install_postfix_advanced.sh @@ -3355,6 +3355,49 @@ else fi +## - Install a cronjob for checking if mailservice is running.. +## - +echononl " Install a cronjob for checking if mailservice is running.." +crontab -l > /tmp/tmp_crontab +if ! grep -q -E "/root/bin/monitoring/check_postfix.sh" /tmp/tmp_crontab 2> /dev/null ; then + echo "" >> /tmp/tmp_crontab + echo "# - Check if postfix mailservice is running. Restart service if needed." >> /tmp/tmp_crontab + echo "# -" >> /tmp/tmp_crontab + echo "*/5 * * * * /root/bin/monitoring/check_postfix.sh" >> /tmp/tmp_crontab + crontab /tmp/tmp_crontab > $log_file 2>&1 + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "$(cat $log_file)" + fi +else + echo_skipped +fi + + +## - Install a cronjob that checks the LOG file for fatal errors.. +## - +echononl " Install a cronjob that checks the LOG file for fatal errors.." +crontab -l > /tmp/tmp_crontab +if ! grep -q -E "/root/bin/postfix/check-postfix-fatal-errors.sh" /tmp/tmp_crontab 2> /dev/null ; then + echo "" >> /tmp/tmp_crontab + echo "# - Check Postfix E-Mail LOG file for 'fatal' errors.." >> /tmp/tmp_crontab + echo "# -" >> /tmp/tmp_crontab + echo "*/5 * * * * /root/bin/postfix/check-postfix-fatal-errors.sh" >> /tmp/tmp_crontab + crontab /tmp/tmp_crontab > $log_file 2>&1 + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "$(cat $log_file)" + fi +else + echo_skipped +fi + + + ## - restart postfix ## - echononl " Restart postfix" diff --git a/install_postfix_base.sh b/install_postfix_base.sh index 0f7465e..d9988bc 100755 --- a/install_postfix_base.sh +++ b/install_postfix_base.sh @@ -1046,6 +1046,48 @@ else echo_skipped fi + +## - Install a cronjob for checking if mailservice is running.. +## - +echononl " Install a cronjob for checking if mailservice is running.." +crontab -l > /tmp/tmp_crontab +if ! grep -q -E "/root/bin/monitoring/check_postfix.sh" /tmp/tmp_crontab 2> /dev/null ; then + echo "" >> /tmp/tmp_crontab + echo "# - Check if postfix mailservice is running. Restart service if needed." >> /tmp/tmp_crontab + echo "# -" >> /tmp/tmp_crontab + echo "*/5 * * * * /root/bin/monitoring/check_postfix.sh" >> /tmp/tmp_crontab + crontab /tmp/tmp_crontab > $log_file 2>&1 + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "$(cat $log_file)" + fi +else + echo_skipped +fi + + +## - Install a cronjob that checks the LOG file for fatal errors.. +## - +echononl " Install a cronjob that checks the LOG file for fatal errors.." +crontab -l > /tmp/tmp_crontab +if ! grep -q -E "/root/bin/postfix/check-postfix-fatal-errors.sh" /tmp/tmp_crontab 2> /dev/null ; then + echo "" >> /tmp/tmp_crontab + echo "# - Check Postfix E-Mail LOG file for 'fatal' errors.." >> /tmp/tmp_crontab + echo "# -" >> /tmp/tmp_crontab + echo "*/5 * * * * /root/bin/postfix/check-postfix-fatal-errors.sh" >> /tmp/tmp_crontab + crontab /tmp/tmp_crontab > $log_file 2>&1 + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "$(cat $log_file)" + fi +else + echo_skipped +fi + ## - rebuld alias database ## - echononl " Rebuld alias database"