scripts/webalizer.sh

40 lines
884 B
Bash

#!/bin/sh
# webalizer cronjob
# 07/2006 ore
CONF_DIR=/etc/webalizer.d
WEBALIZER=/usr/bin/webalizer
[ -f ${WEBALIZER} ] || exit 0
# for all configs
for config in $CONF_DIR/*.conf; do
logfile=$(awk '/^LogFile/{print $2}' $config)
outputdir=$(awk '/^OutputDir/{print $2}' $config)
# output directory missing - create & parse *all* logs
[ -d ${outputdir} ] || {
mkdir -p $outputdir
# all logs in reversed order
for log in `ls -1tr ${logfile}.*.gz 2> /dev/null`; do
# echo $log
zcat $log | $WEBALIZER -c $config -q -
done
}
# rotated, not compressed logfile
[ -f ${logfile}.1 ] && {
# echo ${logfile}.1
$WEBALIZER -c $config -q ${logfile}.1
}
# current logfile (as given in config)
[ -f ${logfile} ] && {
# echo $logfile
$WEBALIZER -c $config -q
}
done