Hi, find an updated patch attached.
-- Best regards, Sven Strickroth PGP key id F5A9D4C4 @ any key-server
--- orig/buildstatic.sh 2010-12-23 23:59:06.000000000 +0100 +++ new/buildstatic.sh 2013-04-30 21:35:59.000000000 +0200 @@ -1,10 +1,39 @@ -#!/bin/sh +#!/bin/bash ## ## buildstatic.sh, written by Sergey B Kirpichev <skirpic...@gmail.com> +## extended by Sven Strickroth <em...@cs-ware.de> ## ## Build all static html reports from AWStats data (Debian specific) ## +function generateStaticPagesForSpecificMonth { + YEAR=$1 + MONTH=$2 + for c in `/bin/ls -1 awstats.*.conf 2>/dev/null | \ + /bin/sed 's/^awstats\.\(.*\)\.conf/\1/'` awstats + do + mkdir -p /var/cache/awstats/$c/$YEAR/$MONTH/ + + if ! nice -n $AWSTATS_NICE $BUILDSTATICPAGES \ + -config=$c \ + -year=$YEAR \ + -month=$MONTH \ + -lang=$AWSTATS_LANG \ + -staticlinksext=${AWSTATS_LANG}.html \ + -dir=/var/cache/awstats/$c/$YEAR/$MONTH/ >$ERRFILE 2>&1 + then + cat $ERRFILE >&2 # an error occurred + fi + done +} + +function generateStaticPages { + if [[ `date +%d` == 01 ]]; then + generateStaticPagesForSpecificMonth `perl -e '@date = localtime(time()-(24*3600)); $date[5]+=1900; print $date[5];'` `perl -e '@date = localtime(time()-(24*3600)); ++$date[4]; if ($date[4] < 10){$date[4]="0".$date[4];} print $date[5];'` + fi + generateStaticPagesForSpecificMonth `date +%Y` `date +%m` +} + set -e DEFAULT=/etc/default/awstats @@ -28,19 +57,4 @@ cd /etc/awstats -for c in `/bin/ls -1 awstats.*.conf 2>/dev/null | \ - /bin/sed 's/^awstats\.\(.*\)\.conf/\1/'` awstats -do - mkdir -p /var/cache/awstats/$c/$YEAR/$MONTH/ - - if ! nice -n $AWSTATS_NICE $BUILDSTATICPAGES \ - -config=$c \ - -year=$YEAR \ - -month=$MONTH \ - -lang=$AWSTATS_LANG \ - -staticlinksext=${AWSTATS_LANG}.html \ - -dir=/var/cache/awstats/$c/$YEAR/$MONTH/ >$ERRFILE 2>&1 - then - cat $ERRFILE >&2 # an error occurred - fi -done +generateStaticPages