From af4a0e2aa50b5be2ad6d0d9c90a4ebcf2e9bca51 Mon Sep 17 00:00:00 2001 From: pezcurrel Date: Thu, 18 Apr 2024 08:13:33 +0200 Subject: [PATCH] Added mail results code --- web/clitools/maintain/pcloop.bash | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/web/clitools/maintain/pcloop.bash b/web/clitools/maintain/pcloop.bash index 06c9aa6..dccf8dd 100755 --- a/web/clitools/maintain/pcloop.bash +++ b/web/clitools/maintain/pcloop.bash @@ -2,6 +2,13 @@ trap "exit" INT basedir=`dirname "$0"` cd "$basedir/.." +mailcfgfp="../conf/mail.conf" +mailmta=`cat "${mailcfgfp}" | grep -P '^mta=' | sed -e 's/^mta=//' -e 's/^"//' -e 's/"$//'` +mailfrom=`cat "${mailcfgfp}" | grep -P '^from=' | sed -e 's/^from=//' -e 's/^"//' -e 's/"$//'` +mailto=`cat "${mailcfgfp}" | grep -P '^to=' | sed -e 's/^to=//' -e 's/^"//' -e 's/"$//'` +subj="" +lastmailts=0 +newmailwait=$((12*60*60)) resurrfp=".pcresurrectdone" cmdlogfp="peerscrawl.log" logfp="pcloop.log" @@ -20,8 +27,15 @@ while true; do log "### Starting peerscrawl.php with the default gracetime ###" ./peerscrawl.php -e peerscrawl.exclude &> $cmdlogfp fi + pcrv=$? tail $cmdlogfp >> $logfp log "### THE END ###" cp "$cmdlogfp" "${cmdlogfp}.old" + now=$((`date "+%s"`+0)) + if [ $(($now-$lastmailts)) -gt $newmailwait ]; then + [ $pcrv == "0" ] && subj="peerscrawl.php: tutto ok :-)" || subj="peerscrawl.php: uscito con errore: ${pcrv} :-(" + tail $logfp | s-nail -s "${subj}" -S v15-compat -S from="${mailfrom}" -S smtp-use-starttls -S mta="${mailmta}" "${mailto}" + lastmailts=$((`date "+%s"`+0)) + fi done exit 0;