From 4cc2ceeb2c70ce30dbff158aca632c0c678ae257 Mon Sep 17 00:00:00 2001 From: Clinton Ebadi Date: Tue, 4 Mar 2014 03:41:41 -0500 Subject: [PATCH] Base webalizer cron job --- debian/hcoop-webalizer.cron.daily | 57 +++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 debian/hcoop-webalizer.cron.daily diff --git a/debian/hcoop-webalizer.cron.daily b/debian/hcoop-webalizer.cron.daily new file mode 100644 index 0000000..5256e13 --- /dev/null +++ b/debian/hcoop-webalizer.cron.daily @@ -0,0 +1,57 @@ +#!/bin/sh +# /etc/cron.daily/webalizer: Webalizer daily maintenance script +# This script was originally written by +# Remco van de Meent +# and now, all rewrited by Jose Carlos Medeiros + +# This script just run webalizer against all .conf files in /etc/webalizer + +WEBALIZER=/usr/bin/webalizer +WEBALIZER_CONFDIR=/etc/webalizer + +[ -x ${WEBALIZER} ] || exit 0; +[ -d ${WEBALIZER_CONFDIR} ] || exit 0; + +for i in ${WEBALIZER_CONFDIR}/*.conf; do + # exists ? + [ -f $i ] || continue; + + # run agains a rotated or normal logfile + LOGFILE=`awk '$1 ~ /^LogFile$/ {print $2}' $i`; + + # empty ? + [ -s "${LOGFILE}" ] || continue; + # readable ? + [ -r "${LOGFILE}" ] || continue; + + # there was a output ? + OUTDIR=`awk '$1 ~ /^OutputDir$/ {print $2}' $i`; + # exists something ? + [ "${OUTDIR}" != "" ] || continue; + # its a directory ? + [ -d ${OUTDIR} ] || continue; + # its writable ? + [ -w ${OUTDIR} ] || continue; + + # Run Really quietly, exit with status code if !0 + ${WEBALIZER} -c ${i} -Q || continue; + RET=$?; + + # Non rotated log file + NLOGFILE=`awk '$1 ~ /^LogFile$/ {gsub(/\.[0-9]+(\.gz)?/,""); print $2}' $i`; + + # check current log, if last log is a rotated logfile + if [ "${LOGFILE}" != "${NLOGFILE}" ]; then + # empty ? + [ -s "${NLOGFILE}" ] || continue; + # readable ? + [ -r "${NLOGFILE}" ] || continue; + + ${WEBALIZER} -c ${i} -Q ${NLOGFILE}; + RET=$?; + fi; +done; + +# exit with webalizer's exit code +exit $RET; + -- 2.20.1