#!/bin/sh # # exicyclog (rotate Exim log) + eximstats (generates statistics from Exim) # # in /etc/sysconfig/exim # # EXIM_REPORT_WEEKLY_SEND = yes/no # EXIM_REPORT_WEEKLY_HTML = yes/no # cd /var/log/exim if [ -f /etc/sysconfig/exim ]; then source /etc/sysconfig/exim fi if [ "$EXIM_REPORT_WEEKLY_SEND" == "yes" ] || [ "$EXIM_REPORT_WEEKLY_HTML" == "yes" ]; then if [ ! -f /var/log/exim/main.log ]; then exec /usr/bin/exicyclog exit 0 fi day=`date +%Y%m%d` report=weekly_report-$day.log eximstatsdir=/var/www/eximstats/$day eximstats main.log > $report chmod 640 $report chown mail:mail $report # create HTML report ? if [ "$EXIM_REPORT_WEEKLY_HTML" = yes ]; then mkdir -p $eximstatsdir eximstats -html -charts -chartdir $eximstatsdir main.log > $eximstatsdir/index.html fi # send $report via mail to postmaster ? if [ "$EXIM_REPORT_WEEKLY_SEND" == "yes" ]; then mail -s "$(sed -n '2{p;q;}' < $report) ($(hostname))" postmaster < $report fi # rotate $report if [ -f $report ]; then [ -f $report.gz ] && rm -f $report.gz gzip -f -9 $report rm -f $report fi fi exec /usr/bin/exicyclog