root/alternc-webalizer/trunk/alternc-webalizer

Revision 2177, 1.2 kB (checked in by anarcat, 5 months ago)

correctly declare functions

I forgot to mention that the original patch here is from Patrick Hétu.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1 #!/bin/sh
2
3 if [ -e /etc/alternc/webalizer.conf ]
4 then
5     . /etc/alternc/webalizer.conf
6 fi
7
8 if [ -z "$ACCESSLOG" ]
9 then
10     ACCESSLOG="/var/log/apache/access.log.1"
11 fi
12
13 CACHEDIR="/var/cache/alternc-webalizer"
14 DNSCACHE="/var/cache/alternc-webalizer/.dns.cache"
15 TMPLOG=`mktemp -p /tmp`
16 mkdir -p $CACHEDIR
17 trap cleanup 1 2 15
18
19 cleanup() {
20     rm -f $TMPLOG
21     rm -rf $CACHEDIR/*
22 }
23
24 dostat() {
25     read LANG DOM DIR USER
26     while [ "$DOM" ]
27     do   
28       if [ ! -d "$DIR" ]; then
29         mkdir -p "$DIR"
30         chown www-data:$USER "$DIR"
31       fi
32       export LC_ALL="$LANG"
33       export LC_MESSAGES="$LANG"
34       export LANG
35
36       # first run: resolve IPs in cache
37       grep -h " $DOM$" $ACCESSLOG | tee $TMPLOG | /usr/bin/webalizer -c $CACHEDIR/$DOM.conf -N 5 -D $DNSCACHE -
38       # second run: process the stats
39       /usr/bin/webalizer -c $CACHEDIR/$DOM.conf -N 0 -D $DNSCACHE $TMPLOG 2>/dev/null
40       read LANG DOM DIR USER
41     done
42 }
43
44 # Clear the cache dir
45 rm -f $CACHEDIR/*
46 # Fill the cache dir
47 /usr/lib/alternc/webalizer.cache.php
48
49 # Launch the stat
50 mysql --defaults-file=/etc/alternc/my.cnf -B -e "SELECT lang,hostname,dir,uid FROM stats" |grep -v "^lang" | dostat
51
52 cleanup
Note: See TracBrowser for help on using the browser.