Commit | Line | Data |
---|---|---|
4cc2ceeb 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 | |
4bc4afc4 | 8 | # Modified for use at HCoop with config and output stored in AFS |
4cc2ceeb CE |
9 | |
10 | WEBALIZER=/usr/bin/webalizer | |
4bc4afc4 | 11 | WEBALIZER_CONFDIR=/afs/hcoop.net/common/etc/domtool/webalizer/config |
4cc2ceeb CE |
12 | |
13 | [ -x ${WEBALIZER} ] || exit 0; | |
14 | [ -d ${WEBALIZER_CONFDIR} ] || exit 0; | |
15 | ||
4bc4afc4 CE |
16 | WEBALIZER="/usr/bin/k5start -U -K 300 -t -f /etc/keytabs/service/webalizer ${WEBALIZER}" |
17 | ||
18 | #${WEBALIZER} -c /etc/webalizer/main.conf -Q || continue | |
19 | ||
4cc2ceeb CE |
20 | for i in ${WEBALIZER_CONFDIR}/*.conf; do |
21 | # exists ? | |
22 | [ -f $i ] || continue; | |
23 | ||
24 | # run agains a rotated or normal logfile | |
25 | LOGFILE=`awk '$1 ~ /^LogFile$/ {print $2}' $i`; | |
26 | ||
27 | # empty ? | |
28 | [ -s "${LOGFILE}" ] || continue; | |
29 | # readable ? | |
30 | [ -r "${LOGFILE}" ] || continue; | |
31 | ||
32 | # there was a output ? | |
33 | OUTDIR=`awk '$1 ~ /^OutputDir$/ {print $2}' $i`; | |
34 | # exists something ? | |
35 | [ "${OUTDIR}" != "" ] || continue; | |
36 | # its a directory ? | |
37 | [ -d ${OUTDIR} ] || continue; | |
38 | # its writable ? | |
39 | [ -w ${OUTDIR} ] || continue; | |
40 | ||
41 | # Run Really quietly, exit with status code if !0 | |
42 | ${WEBALIZER} -c ${i} -Q || continue; | |
43 | RET=$?; | |
44 | ||
45 | # Non rotated log file | |
46 | NLOGFILE=`awk '$1 ~ /^LogFile$/ {gsub(/\.[0-9]+(\.gz)?/,""); print $2}' $i`; | |
47 | ||
48 | # check current log, if last log is a rotated logfile | |
49 | if [ "${LOGFILE}" != "${NLOGFILE}" ]; then | |
50 | # empty ? | |
51 | [ -s "${NLOGFILE}" ] || continue; | |
52 | # readable ? | |
53 | [ -r "${NLOGFILE}" ] || continue; | |
54 | ||
55 | ${WEBALIZER} -c ${i} -Q ${NLOGFILE}; | |
56 | RET=$?; | |
57 | fi; | |
58 | done; | |
59 | ||
60 | # exit with webalizer's exit code | |
61 | exit $RET; | |
62 |