wok rev 5959

awstats: avoid alias conflicts + update script
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Aug 04 11:50:34 2010 +0200 (2010-08-04)
parents 2c2c78a87d55
children 103cd0c4d016
files awstats/receipt awstats/stuff/update
line diff
     1.1 --- a/awstats/receipt	Wed Aug 04 00:32:44 2010 +0200
     1.2 +++ b/awstats/receipt	Wed Aug 04 11:50:34 2010 +0200
     1.3 @@ -31,12 +31,23 @@
     1.4  	cp -a $src/wwwroot/cgi-bin/awstats.pl  $fs/var/www/cgi-bin
     1.5  	cp -a $src/wwwroot/cgi-bin/awstats.model.conf  $fs/etc/awstats
     1.6  	
     1.7 -	cp stuff/awstats-apache.conf $fs/usr/share/awstats/extras
     1.8 -	cp stuff/awstats-lighttpd.conf $fs/usr/share/awstats/extras
     1.9 +	cp stuff/* $fs/usr/share/awstats/extras
    1.10  
    1.11  	# Add a link using google map
    1.12  	sed -i 's|Full Whois Field"|Full Whois Field <a href=\\"http://en.utrace.de/?query=".$HostResolved."\\">?</a>"|' \
    1.13  		$fs/usr/share/awstats/plugins/hostinfo.pm
    1.14 +
    1.15 +	# Avoid alias conflits
    1.16 +	for i in classes css icon ; do
    1.17 +		sed -i "s| /$i| /awstats$i|" \
    1.18 +			$fs/usr/share/awstats/extras/awstats-apache.conf
    1.19 +		sed -i "s|\"/$i|\"/awstats$i|" \
    1.20 +			$fs/usr/share/awstats/extras/awstats-lighttpd.conf
    1.21 +	done
    1.22 +	sed -i -e '/\/css\//d' -e 's|DirIcons="/icon"|DirIcons="/awstatsicon"|' \
    1.23 +		$fs/etc/awstats/awstats.model.conf
    1.24 +	sed -i 's/classes/awstatsclasses/' \
    1.25 +		$fs/usr/share/awstats/plugins/graphapplet.pm
    1.26  }
    1.27  
    1.28  post_install()
    1.29 @@ -67,6 +78,11 @@
    1.30  			/etc/init.d/lighttpd restart
    1.31  		fi
    1.32  	fi
    1.33 +	cat <<EOT
    1.34 +You should add in your crontab something like;
    1.35 +
    1.36 +0 0 * * * /usr/share/awstats/extras/update
    1.37 +EOT
    1.38  }
    1.39  
    1.40  post_remove()
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/awstats/stuff/update	Wed Aug 04 11:50:34 2010 +0200
     2.3 @@ -0,0 +1,44 @@
     2.4 +#!/bin/sh
     2.5 +
     2.6 +list_vhosts()
     2.7 +{
     2.8 +[ -d /etc/apache ] && cat /etc/apache/conf.d/* | awk ' \
     2.9 +/ServerName/ { name=$2 }
    2.10 +/CustomLog/  { file=$2 }
    2.11 +{
    2.12 +    if ( name != "" && file != "" ) {
    2.13 +    	printf "%s %s\n",name,file
    2.14 +       	name=""
    2.15 +    	file=""
    2.16 +    }
    2.17 +}
    2.18 +' | sed '/localhost/d;/\//!d'
    2.19 +[ -d /etc/lighttpd ] && grep -v '^ *#' /etc/lighttpd/vhosts.conf | awk ' \
    2.20 +/HTTP."host"/ { name=$3 ; file="" }
    2.21 +/accesslog.filename/  { file=$3 }
    2.22 +{
    2.23 +    if ( name != "" && file != "" ) {
    2.24 +    	printf "%s %s\n",name,file
    2.25 +       	name=""
    2.26 +    }
    2.27 +}
    2.28 +' | sed 's/\$//;s/\^//;s/\\//g;s/"//g;/(/d'
    2.29 +}
    2.30 +
    2.31 +cd /etc/awstats
    2.32 +
    2.33 +list_vhosts | while read name logfile; do
    2.34 +	[ -s $logfile ] || continue
    2.35 +	[ -s /etc/awstats/awstats.$name.conf ] && continue
    2.36 +	mkdir -p /var/lib/awstats/$name
    2.37 +	sed -e "s|LogFile=.*|LogFile=\"$logfile\"|" \
    2.38 +	    -e "s|SiteDomain=.*|SiteDomain=\"$name\"|" \
    2.39 +	    -e "s|DirData=.*|DirData=\"/var/lib/awstats/$name\"|" \
    2.40 +	    -e "s|LogoLink=.*|LogoLink=\"http://$name/\"|" \
    2.41 +	    < /etc/awstats/awstats.model.conf > /etc/awstats/awstats.$name.conf
    2.42 +done
    2.43 +
    2.44 +for i in $(grep -l '^DirData="/var/lib/awstats' *.conf); do
    2.45 +	/var/www/cgi-bin/awstats.pl \
    2.46 +		config=$(echo $i | sed 's/awstats\.\(.*\)\.conf/\1/') -update
    2.47 +done