@@ -15,14 +15,13 @@ source $HESTIA/conf/hestia.conf
1515PATH=" $PATH :/usr/local/sbin:/sbin:/usr/sbin:/root/bin"
1616
1717send_email_report () {
18+ local mail_service=" $1 "
19+ journalctl --no-pager --reverse --since=-1m --unit " $mail_service " >> " $tmpfile " 2>&1
1820 email=$( grep CONTACT $HESTIA /data/users/admin/user.conf)
1921 email=$( echo " $email " | cut -f 2 -d " '" )
20- tmpfile=$( mktemp)
21- subj=" $( hostname) : $MAIL_SYSTEM restart failed"
22- service $MAIL_SYSTEM configtest >> $tmpfile 2>&1
23- service $MAIL_SYSTEM restart >> $tmpfile 2>&1
24- cat $tmpfile | $SENDMAIL -s " $subj " $email
25- rm -f $tmpfile
22+ subj=" $( hostname) : $mail_service restart failed"
23+ cat " $tmpfile " | $SENDMAIL -s " $subj " $email
24+ [[ -f " $tmpfile " ]] && rm -f $tmpfile
2625}
2726
2827
@@ -46,19 +45,20 @@ if [ -z "$MAIL_SYSTEM" ] || [ "$MAIL_SYSTEM" = 'remote' ]; then
4645 exit
4746fi
4847
48+ tmpfile=$( mktemp)
4949# Restart IMAP system if present
5050if [ ! -z " $IMAP_SYSTEM " ]; then
51- $BIN /v-restart-service $IMAP_SYSTEM > /dev/null 2>&1
51+ $BIN /v-restart-service $IMAP_SYSTEM >> $tmpfile 2>&1
5252 if [ $? -ne 0 ]; then
53- send_email_report
53+ send_email_report " $IMAP_SYSTEM "
5454 check_result $E_RESTART " $IMAP_SYSTEM restart failed"
5555 fi
5656fi
5757
5858# Restart mail system
59- $BIN /v-restart-service $MAIL_SYSTEM > /dev/null 2>&1
59+ $BIN /v-restart-service $MAIL_SYSTEM >> $tmpfile 2>&1
6060if [ $? -ne 0 ]; then
61- send_email_report
61+ send_email_report " $MAIL_SYSTEM "
6262 check_result $E_RESTART " $MAIL_SYSTEM restart failed"
6363fi
6464
7272# Hestia #
7373# ----------------------------------------------------------#
7474
75+ [[ -f " $tmpfile " ]] && rm -f $tmpfile
7576exit
0 commit comments