update webalizer script
This commit is contained in:
parent
e5d3ca222d
commit
a1930dce37
51
webalizer.sh
51
webalizer.sh
@ -1,39 +1,68 @@
|
||||
#!/bin/sh
|
||||
|
||||
# webalizer cronjob
|
||||
# 07/2006 ore
|
||||
# 02/2007 ore
|
||||
|
||||
CONF_DIR=/etc/webalizer.d
|
||||
WEBALIZER=/usr/bin/webalizer
|
||||
|
||||
[ -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 config in $CONF_DIR/*.conf; do
|
||||
[ "$VERBOSE" = "1" ] && echo "Using config '$config'"
|
||||
|
||||
logfile=$(awk '/^LogFile/{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
|
||||
[ -d ${outputdir} ] || {
|
||||
[ "$VERBOSE" = "1" ] && echo " creating '$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
|
||||
# all logs in reversed order
|
||||
for log in `ls -1tr ${logfile}.*.gz 2> /dev/null`; do
|
||||
[ "$VERBOSE" = "1" ] && echo " parsing '$log'"
|
||||
zcat $log | $WEBALIZER -c $config -q -
|
||||
done
|
||||
}
|
||||
|
||||
# rotated, not compressed logfile
|
||||
[ -s ${logfile}.1 ] && {
|
||||
# echo ${logfile}.1
|
||||
$WEBALIZER -c $config -q ${logfile}.1
|
||||
[ "$VERBOSE" = "1" ] && echo " parsing '${logfile}.1'"
|
||||
$WEBALIZER -c $config -q ${logfile}.1
|
||||
}
|
||||
|
||||
# current logfile (as given in config)
|
||||
[ -s ${logfile} ] && {
|
||||
# echo $logfile
|
||||
$WEBALIZER -c $config -q
|
||||
[ "$VERBOSE" = "1" ] && echo " parsing '${logfile}'"
|
||||
$WEBALIZER -c $config -q
|
||||
}
|
||||
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user