update webalizer script

This commit is contained in:
Olaf Rempel 2007-02-09 10:42:00 +01:00
parent e5d3ca222d
commit a1930dce37

View File

@ -1,38 +1,67 @@
#!/bin/sh #!/bin/sh
# webalizer cronjob # webalizer cronjob
# 07/2006 ore # 02/2007 ore
CONF_DIR=/etc/webalizer.d CONF_DIR=/etc/webalizer.d
WEBALIZER=/usr/bin/webalizer WEBALIZER=/usr/bin/webalizer
[ -f ${WEBALIZER} ] || exit 0 [ -f ${WEBALIZER} ] || exit 0
for arg in "$@"; do
case "$arg" in
-h|--help)
echo "Usage: $0 [--help] [--verbose] [--purge]"
exit 0
;;
-v|--verbose)
VERBOSE="1"
;;
-p|--purge)
PURGE="1"
;;
*)
;;
esac
done
# for all configs # for all configs
for config in $CONF_DIR/*.conf; do for config in $CONF_DIR/*.conf; do
[ "$VERBOSE" = "1" ] && echo "Using config '$config'"
logfile=$(awk '/^LogFile/{print $2}' $config) logfile=$(awk '/^LogFile/{print $2}' $config)
outputdir=$(awk '/^OutputDir/{print $2}' $config) outputdir=$(awk '/^OutputDir/{print $2}' $config)
# delete output directory, to regenerate all
[ "$PURGE" = "1" ] && {
[ "$VERBOSE" = "1" ] && echo " purging '$outputdir'"
rm -rf $outputdir
}
# output directory missing - create & parse *all* logs # output directory missing - create & parse *all* logs
[ -d ${outputdir} ] || { [ -d ${outputdir} ] || {
[ "$VERBOSE" = "1" ] && echo " creating '$outputdir'"
mkdir -p $outputdir mkdir -p $outputdir
# all logs in reversed order # all logs in reversed order
for log in `ls -1tr ${logfile}.*.gz 2> /dev/null`; do for log in `ls -1tr ${logfile}.*.gz 2> /dev/null`; do
# echo $log [ "$VERBOSE" = "1" ] && echo " parsing '$log'"
zcat $log | $WEBALIZER -c $config -q - zcat $log | $WEBALIZER -c $config -q -
done done
} }
# rotated, not compressed logfile # rotated, not compressed logfile
[ -s ${logfile}.1 ] && { [ -s ${logfile}.1 ] && {
# echo ${logfile}.1 [ "$VERBOSE" = "1" ] && echo " parsing '${logfile}.1'"
$WEBALIZER -c $config -q ${logfile}.1 $WEBALIZER -c $config -q ${logfile}.1
} }
# current logfile (as given in config) # current logfile (as given in config)
[ -s ${logfile} ] && { [ -s ${logfile} ] && {
# echo $logfile [ "$VERBOSE" = "1" ] && echo " parsing '${logfile}'"
$WEBALIZER -c $config -q $WEBALIZER -c $config -q
} }