From 1a875c003e0e9921c047fc594b9d6597f8f342de Mon Sep 17 00:00:00 2001 From: Christoph Date: Sun, 13 May 2018 23:08:15 +0200 Subject: [PATCH] install_amavis.sh: write crontop for checking, if AMaVis is running. --- install_amavis.sh | 75 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/install_amavis.sh b/install_amavis.sh index 4e5c99a..8ccd8de 100755 --- a/install_amavis.sh +++ b/install_amavis.sh @@ -3600,6 +3600,81 @@ else fi +## - Add a crontab to check if AMaViS is running. +## - +echononl " Add a cronjobs to to check if AMaViS is running .." +if [[ -f "/root/bin/monitoring/check_amavis.pl" ]]; then + if [[ -f "$crontab_backup_file" ]]; then + if ! $(grep -q -E "*\s+/root/bin/monitoring/check_amavis.pl\s+" "$crontab_backup_file" 2>/dev/null) ; then + cat << EOF >> $crontab_backup_file + +# - Check if Amavis is running. Restart service if needed.. +# - +*/5 * * * * /root/bin/monitoring/check_amavis.pl -f postmaster -t do-not-reply -s 127.0.0.1 -p 10024 +EOF + if [[ $? -eq 0 ]]; then + echo_done + else + echo_failed + fi + else + echo_skipped + fi + elif [[ -f "/var/spool/cron/crontabs/root" ]] ; then + + installed=false + installation_failed=false + + crontab -l > /tmp/tmp_crontab 2> $tmp_err_msg + if [[ $? -ne 0 ]] ; then + installation_failed=true + fi + + if ! $(grep -q -E "*\s+/root/bin/monitoring/check_amavis.pl\s+" "/tmp/tmp_crontab" 2>/dev/null) ; then + + cat << EOF >> /tmp/tmp_crontab + +# - Check if Amavis is running. Restart service if needed.. +# - +*/5 * * * * /root/bin/monitoring/check_amavis.pl -f postmaster -t do-not-reply -s 127.0.0.1 -p 10024 +EOF + if [[ $? -ne 0 ]] ; then + installation_failed=true + fi + + crontab /tmp/tmp_crontab > /dev/null 2>> $tmp_err_msg + if [[ $? -ne 0 ]] ; then + installation_failed=true + fi + + rm /tmp/tmp_crontab > /dev/null 2>> $tmp_err_msg + if [[ $? -ne 0 ]] ; then + installation_failed=true + fi + + if ! $installation_failed ; then + echo_ok + else + echo_failed + fi + + else + echo_skipped + rm /tmp/tmp_crontab > /dev/null 2>> $tmp_err_msg + if [[ $? -ne 0 ]] ; then + installation_failed=true + fi + if $installation_failed ; then + error "$(cat $tmp_err_msg)" + fi + fi + else + echo_skipped + fi +else + echo_skipped +fi + ## - Add a crontab to cleanup the quarantine folder ## - echononl " Add a cronjobs to cleanup the quarantine folder"