Package: awstats
Version: 6.9.5~dfsg-5
Severity: normal

Enable AWSTATS_ENABLE_BUILDSTATICPAGES in /etc/defaults/awstats (which is
enabled by default), /usr/share/awstats/tools/buildstatic.sh is executed
every day using cron (for me it's executed at 3:10).

When a new month begins (e.g. May, 1st) stats of the last day of the last
month (e.g. April, 30th) are incomplete (depending on when cron executes
the script). In my case the stats of the last day (April, 30) is only
available up to 3:10 the rest of the day is missing.

I've attached patch fixing this issue.

-- System Information:
Debian Release: 6.0.7
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-5-amd64 (SMP w/1 CPU core)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages awstats depends on:
ii  perl                   5.10.1-17squeeze6 Larry Wall's Practical Extraction 

Versions of packages awstats recommends:
ii  coreutils                     8.5-1      GNU core utilities
ii  libnet-xwhois-perl            0.90-3     Whois Client Interface for Perl5

Versions of packages awstats suggests:
pn  apache2 | httpd               <none>     (no description available)
pn  libgeo-ipfree-perl            <none>     (no description available)
pn  libnet-dns-perl               <none>     (no description available)
pn  libnet-ip-perl                <none>     (no description available)
pn  liburi-perl                   <none>     (no description available)

-- no debconf information
--- /usr/share/awstats/tools/buildstatic.sh.orig        2010-12-23 
23:59:06.000000000 +0100
+++ /usr/share/awstats/tools/buildstatic.sh     2013-04-30 21:20:08.000000000 
+0200
@@ -1,10 +1,37 @@
-#!/bin/sh
+#!/bin/bash
 ##
 ## buildstatic.sh, written by Sergey B Kirpichev <skirpic...@gmail.com>
 ##
 ## Build all static html reports from AWStats data (Debian specific)
 ##
 
+function generateStaticPagesForSpecificMonth {
+       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 +55,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

Reply via email to