2 # /etc/cron.daily/webalizer: Webalizer daily maintenance script
3 # This script was originally written by
4 # Remco van de Meent <remco@debian.org>
5 # and now, all rewrited by Jose Carlos Medeiros <jose@psabs.com.br>
7 # This script just run webalizer against all .conf files in /etc/webalizer
8 # Modified for use at HCoop with config and output stored in AFS
10 WEBALIZER
=/usr
/bin
/webalizer
11 WEBALIZER_CONFDIR
=/afs
/hcoop.net
/common
/etc
/domtool
/webalizer
/config
12 WEBBWSTATSDIR
=/afs
/hcoop.net
/user
/h
/hc
/hcoop
/portal-root
/etc
/stats
14 [ -x ${WEBALIZER} ] ||
exit 0;
15 [ -d ${WEBALIZER_CONFDIR} ] ||
exit 0;
17 /usr
/bin
/k5start
-U -b -K 300 -t \
18 -p /var
/run
/webalizer-k5start.pid \
19 -f /etc
/keytabs
/service
/webalizer
21 #${WEBALIZER} -c /etc/webalizer/main.conf -Q || continue
23 for i
in ${WEBALIZER_CONFDIR}/*/*.conf
; do
25 [ -f $i ] ||
continue;
27 # run agains a rotated or normal logfile
28 LOGFILE
=`awk '$1 ~ /^LogFile$/ {print $2}' $i`;
31 [ -s "${LOGFILE}" ] ||
continue;
33 [ -r "${LOGFILE}" ] ||
continue;
35 # there was a output ?
36 OUTDIR
=`awk '$1 ~ /^OutputDir$/ {print $2}' $i`;
38 [ "${OUTDIR}" != "" ] ||
continue;
40 [ -d ${OUTDIR} ] ||
continue;
42 [ -w ${OUTDIR} ] ||
continue;
44 # Run Really quietly, exit with status code if !0
45 ${WEBALIZER} -c ${i} -Q ||
continue;
48 # Non rotated log file
49 NLOGFILE
=`awk '$1 ~ /^LogFile$/ {gsub(/\.[0-9]+(\.gz)?/,""); print $2}' $i`;
51 # check current log, if last log is a rotated logfile
52 if [ "${LOGFILE}" != "${NLOGFILE}" ]; then
54 [ -s "${NLOGFILE}" ] ||
continue;
56 [ -r "${NLOGFILE}" ] ||
continue;
58 ${WEBALIZER} -c ${i} -Q ${NLOGFILE};
63 /usr
/local
/sbin
/webbw
> $WEBBWSTATSDIR/webbw
64 /usr
/local
/sbin
/webbw
1 > $WEBBWSTATSDIR/webbw.last
65 /usr
/local
/sbin
/webbw
2 > $WEBBWSTATSDIR/webbw.last2
68 [ -r /var
/run
/webalizer-k5start.pid
] && \
69 kill `cat /var/run/webalizer-k5start.pid `;
71 # exit with webalizer's exit code