ca-install: support multiple webservers, update for new servers
[hcoop/scripts.git] / hcoop-webalizer
CommitLineData
44e4155b
CE
1#!/bin/sh
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>
6
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
9
10WEBALIZER=/usr/bin/webalizer
11WEBALIZER_CONFDIR=/afs/hcoop.net/common/etc/domtool/webalizer/config
12WEBBWSTATSDIR=/afs/hcoop.net/user/h/hc/hcoop/portal-root/etc/stats
13
14[ -x ${WEBALIZER} ] || exit 0;
15[ -d ${WEBALIZER_CONFDIR} ] || exit 0;
16
17/usr/bin/k5start -U -b -K 300 -t \
18 -p /var/run/webalizer-k5start.pid \
19 -f /etc/keytabs/service/webalizer
20
21#${WEBALIZER} -c /etc/webalizer/main.conf -Q || continue
22
23for i in ${WEBALIZER_CONFDIR}/*/*.conf; do
24 # exists ?
25 [ -f $i ] || continue;
26
27 # run agains a rotated or normal logfile
28 LOGFILE=`awk '$1 ~ /^LogFile$/ {print $2}' $i`;
29
30 # empty ?
31 [ -s "${LOGFILE}" ] || continue;
32 # readable ?
33 [ -r "${LOGFILE}" ] || continue;
34
35 # there was a output ?
36 OUTDIR=`awk '$1 ~ /^OutputDir$/ {print $2}' $i`;
37 # exists something ?
38 [ "${OUTDIR}" != "" ] || continue;
39 # its a directory ?
40 [ -d ${OUTDIR} ] || continue;
41 # its writable ?
42 [ -w ${OUTDIR} ] || continue;
43
44 # Run Really quietly, exit with status code if !0
45 ${WEBALIZER} -c ${i} -Q || continue;
46 RET=$?;
47
48 # Non rotated log file
49 NLOGFILE=`awk '$1 ~ /^LogFile$/ {gsub(/\.[0-9]+(\.gz)?/,""); print $2}' $i`;
50
51 # check current log, if last log is a rotated logfile
52 if [ "${LOGFILE}" != "${NLOGFILE}" ]; then
53 # empty ?
54 [ -s "${NLOGFILE}" ] || continue;
55 # readable ?
56 [ -r "${NLOGFILE}" ] || continue;
57
58 ${WEBALIZER} -c ${i} -Q ${NLOGFILE};
59 RET=$?;
60 fi;
61done;
62
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
66
67
68[ -r /var/run/webalizer-k5start.pid ] && \
69 kill `cat /var/run/webalizer-k5start.pid `;
70
71# exit with webalizer's exit code
72exit $RET;
73