From 44e4155bab2c084443ac178765941b6ec36141e4 Mon Sep 17 00:00:00 2001 From: Clinton Ebadi Date: Tue, 4 Dec 2018 23:59:24 -0500 Subject: [PATCH] import hcoop-webalizer cron as script --- hcoop-webalizer | 73 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100755 hcoop-webalizer diff --git a/hcoop-webalizer b/hcoop-webalizer new file mode 100755 index 0000000..1d019fb --- /dev/null +++ b/hcoop-webalizer @@ -0,0 +1,73 @@ +#!/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 +# Modified for use at HCoop with config and output stored in AFS + +WEBALIZER=/usr/bin/webalizer +WEBALIZER_CONFDIR=/afs/hcoop.net/common/etc/domtool/webalizer/config +WEBBWSTATSDIR=/afs/hcoop.net/user/h/hc/hcoop/portal-root/etc/stats + +[ -x ${WEBALIZER} ] || exit 0; +[ -d ${WEBALIZER_CONFDIR} ] || exit 0; + +/usr/bin/k5start -U -b -K 300 -t \ + -p /var/run/webalizer-k5start.pid \ + -f /etc/keytabs/service/webalizer + +#${WEBALIZER} -c /etc/webalizer/main.conf -Q || continue + +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; + +/usr/local/sbin/webbw > $WEBBWSTATSDIR/webbw +/usr/local/sbin/webbw 1 > $WEBBWSTATSDIR/webbw.last +/usr/local/sbin/webbw 2 > $WEBBWSTATSDIR/webbw.last2 + + +[ -r /var/run/webalizer-k5start.pid ] && \ + kill `cat /var/run/webalizer-k5start.pid `; + +# exit with webalizer's exit code +exit $RET; + -- 2.20.1