[Pkg-awstats-devel] Bug#580699: awstats: cron script update.sh does not process multiple stats

Ken Neighbors debian3 at ken.nsds.com
Fri May 7 20:57:13 UTC 2010


Package: awstats
Version: 6.9.5~dfsg-2
Severity: normal
Tags: patch


This report is about the new update.sh script which is called from
cron.  I cannot get it to work for multiple sites as described in
README.Debian.  It always fails (without emitting an error message)
when it finds that SiteDomain is not defined in
/etc/awstats/awstats.conf nor awstats.conf.local (note that I removed
the ">/dev/null" at the end of update.sh in order to see this error
message):

Error: SiteDomain parameter not defined in your config/domain file. You must edit it for using this version of AWStats.
Setup ('/etc/awstats/awstats.conf' file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in 'docs' directory).

root:/etc/awstats# ls -l
total 72
-rw-r--r-- 1 root root 61054 2010-04-26 11:16 awstats.conf
-rw-r--r-- 1 root root   240 2010-04-26 11:39 awstats.conf.local
-rw-r--r-- 1 root root   618 2010-04-26 11:08 awstats.example.com.conf

My SiteDomain is defined in awstats.example.com.conf as described in
README.Debian.  However, update.sh first tries to run awstats.pl on
the default config file (awstats.conf).  It fails and then exits
before trying it on any other config files (because of "set -e" in the
script).

I thought about different was to solve this problem so that the update
script will be able to work with both the default awstats.conf and
with other custom config files.  A couple of solutions which I do not
recommend are: (1) get rid of "set -e" or (2) put the default
"awstats" last in the list instead of first, e.g.:

for c in `/bin/ls -1 awstats.*.conf 2>/dev/null | \
          /bin/sed 's/^awstats\.\(.*\)\.conf/\1/'` awstats
do

However, I recommend fixing the problem by completely removing
"/etc/conf/awstats.conf" from the list of config files to process.  It
always generates an error message when trying to set up awstats for
multiple sites.  I think it is better to treat the single-site case as
a special case of multiple sites where there is only one site, served
by a single config file "awstats.default.conf" which contains one
line:

  Include "awstats.conf"

Here is a description of my patch (attached): Do not use implied
default config file /etc/awstats/awstats.conf but instead require
sysadmin to install one or more explicit config file(s) so that
update.sh and buildstatic.sh will work for either single-site or
multi-site installations.  This fixes the problem where awstats.pl
complains about undefined SiteDomain when using separate config files
as described in README.Debian for multiple stats.

And here is a list of files I changed (attached):

   /usr/share/awstats/tools/buildstatic.sh
   /usr/share/awstats/tools/update.sh
   /usr/share/docs/awstats/README.Debian
   /usr/share/docs/awstats/examples/awstats.default.conf
   debian/rules

Note: the included patch was generated in comparison to the resulting
files from my previous patches (580672, 580692, and 580693).
  http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=580672
  http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=580692
  http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=580693

-- System Information:
Debian Release: 5.0.4
  APT prefers stable
  APT policy: (500, 'stable'), (50, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.26-2-686 (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages awstats depends on:
ii  perl                     5.10.0-19lenny2 Larry Wall's Practical Extraction 

Versions of packages awstats recommends:
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)
ii  liburi-perl                1.35.dfsg.1-1 Manipulates and accesses URI strin

-- no debconf information
-------------- next part --------------
>From 3889a9f7a8dd63ff6c17d169d388c8c131a6a805 Mon Sep 17 00:00:00 2001
From: Ken Neighbors <ken at nsds.com>
Date: Tue, 27 Apr 2010 14:48:25 -0700
Subject: Do not use implied default config file /etc/awstats/awstats.conf but
 instead require sysadmin to install one or more explicit config
 file(s) so that update.sh and buildstatic.sh will work for either
 single-site or multi-site installations.  This fixes the problem where
 awstats.pl complains about undefined SiteDomain when using separate
 config files as described in README.Debian for multiple stats.

---
 debian/README.Debian                 |   66 +++++++++++++--------------------
 debian/buildstatic.sh                |    3 +-
 debian/examples/awstats.default.conf |   35 ++++++++++++++++++
 debian/rules                         |    2 +-
 debian/update.sh                     |    3 +-
 5 files changed, 64 insertions(+), 45 deletions(-)
 create mode 100644 debian/examples/awstats.default.conf

diff --git a/debian/README.Debian b/debian/README.Debian
index ed8b69f..b3ea45b 100644
--- a/debian/README.Debian
+++ b/debian/README.Debian
@@ -8,6 +8,7 @@ Do the following for a simple setup of a single website with Apache 2.x:
 
   * Edit /etc/logrotate.d/apache2 to permit www-data access to logfiles
   * copy /usr/share/doc/awstats/examples/apache.conf to /etc/apache2/conf.d/
+  * copy /usr/share/doc/awstats/examples/awstats.default.conf to /etc/awstats/
   * edit /etc/default/awstats to enable nightly build of static html reports
 
 The above is _NOT_ supported or recommended! Please read the rest of this
@@ -68,52 +69,37 @@ symlink from /var/www/awstats-icon to /usr/share/awstats/icon/.
 Multiple stats
 --------------
 
-To handle multiple stats (eg. using VirtualHosts in Apache) you
-should...
-
- 1) Place all configs in /etc/awstats.
-
- 2) Name the configs "awstats." + whatever you want - ".conf" (eg.
-    awstats.example.com.conf"). But avoid "awstats.awstats.conf.
-
-    To retain use of a common config file containing defaults for all
-    of your sites, consider a scheme such as the following:
- 
-    Make a bunch of awstats.[site_name_here].conf files, and have
-    the first line include the parent awstats.conf file (which by
-    default also includes awstats.conf.local). The remainder of the
-    file should have your site-specific configuration settings, which
-    override the defaults specified in awstats.conf and
-    awstats.conf.local.
- 
-    Here is an example of an awstats.example.com.conf file (of course,
-    tailor the file for your own configuration):
-    
-        Include "/etc/awstats/awstats.conf"
+To handle multiple stats (for example, using VirtualHosts in Apache)
+you should place all your configuration files under /etc/awstats/.
+Name the files "awstats." + whatever you want + ".conf" (for example,
+"awstats.example.com.conf").  But avoid "awstats.awstats.conf".
+
+To retain use of a common config file containing defaults for all of
+your sites, consider a scheme such as the following:
+
+  Make a bunch of awstats.[site_name_here].conf files, and have the
+  first line include the parent awstats.conf file (which by default
+  also includes awstats.conf.local). The remainder of the file should
+  have your site-specific configuration settings, which override the
+  defaults specified in awstats.conf and awstats.conf.local.
+
+  Here is an example of an awstats.example.com.conf file (of course,
+  tailor the file for your own configuration):
+
+        Include "awstats.conf"
         SiteDomain="example.com"
         HostAliases="example.com www.example.com"
         DirData="/var/lib/awstats/example.com"
         LogFile="/var/log/apache2/example.com_access_log"
 
-    This way you can leave awstats.conf alone, and put your
-    server-specific settings into awstats.conf.local, and your
-    site-specific settings into each awstats.[site_name_here].conf
-    file.
-
-    Note, that awstats package cannot safely handle upgrades to
-    locally added config files -- if config options change then the
-    main file is updated (with warnings if edited locally) but extra
-    config files are silently ignored and possibly broken.
-
- 3) Run awstats.pl with each config one by one (have a look at the
-    scripts awstats-update and awstats_updateall.pl in
-    /usr/share/doc/awstats/examples/).
-
- 4) Edit /etc/cron.d/awstats for each site. Possibly a line like this
-    for each site:
+  This way you can leave awstats.conf alone, and put your
+  server-specific settings into awstats.conf.local, and your
+  site-specific settings into each awstats.[site_name_here].conf file.
 
-        20 2 * * * www-data [ -x /usr/lib/cgi-bin/awstats.pl ] && \
-            /usr/lib/cgi-bin/awstats.pl -config=example.com -update >/dev/null
+Note that the awstats package cannot safely handle upgrades to locally
+added config files -- if config options change then the main file is
+updated (with warnings if edited locally), but extra config files are
+silently ignored and possibly broken.
 
 
 Browser and referer stats are missing
diff --git a/debian/buildstatic.sh b/debian/buildstatic.sh
index 8af4c83..a0ec26a 100755
--- a/debian/buildstatic.sh
+++ b/debian/buildstatic.sh
@@ -23,8 +23,7 @@ fi
 cd /etc/awstats
 
 TMPFILE=`mktemp /tmp/awstats.XXXXXXXXXX`
-for c in awstats \
-         `/bin/ls -1 awstats.*.conf 2>/dev/null | \
+for c in `/bin/ls -1 awstats.*.conf 2>/dev/null | \
           /bin/sed 's/^awstats\.\(.*\)\.conf/\1/'`
 do
   Y=`date +%Y`
diff --git a/debian/examples/awstats.default.conf b/debian/examples/awstats.default.conf
new file mode 100644
index 0000000..d63661d
--- /dev/null
+++ b/debian/examples/awstats.default.conf
@@ -0,0 +1,35 @@
+# This is a sample site-specific configuration file for AWStats.  You
+# can copy it into /etc/awstats/ and rename it according to your site
+# name.  Also change the SiteDomain parameter below to your site name
+# and add any additional configuration parameters that you wish to
+# override (see /etc/awstats/awstats.conf for a list of parameters).
+
+# You may create several copies of this file with different names for
+# multiple virtual hosts.  To set defaults for all of your sites, it
+# is recommended that you place your changes in
+# /etc/awstats/awstats.conf.local and leave awstats.conf as it is.
+
+# Note that when a variable is defined both in a config file and in an
+# included file, AWStats will use the last value read for parameters that
+# contains one value and AWStats will concat all values from both files for
+# parameters that are lists of values.
+#
+Include "/etc/awstats/awstats.conf"
+
+# "SiteDomain" must contain the main domain name, or the main intranet web
+# server name, used to reach the web site.
+# If you share the same log file for several virtual web servers, this
+# parameter is used to tell AWStats to filter record that contains records for
+# this virtual host name only (So check that this virtual hostname can be
+# found in your log file and use a personalized log format that include the
+# %virtualname tag).
+# But for multi hosting a better solution is to have one log file for each
+# virtual web server. In this case, this parameter is only used to generate
+# full URL's links when ShowLinksOnUrl option is set to 1.
+# If analyzing mail log, enter here the domain name of mail server.
+# Example: "myintranetserver"
+# Example: "www.domain.com"
+# Example: "ftp.domain.com"
+# Example: "domain.com"
+#
+SiteDomain="localhost"
diff --git a/debian/rules b/debian/rules
index a21daa3..b691154 100755
--- a/debian/rules
+++ b/debian/rules
@@ -34,7 +34,7 @@ DEB_INSTALL_DOCS_ALL = README.TXT
 
 awstats_example_scripts = $(filter-out %/awstats_buildstaticpages.pl,$(wildcard tools/*.pl)) $(wildcard debian/examples/*.sh)
 
-DEB_INSTALL_EXAMPLES_awstats = $(awstats_example_scripts) debian/examples/apache.conf wwwroot/cgi-bin/awstats.model.conf wwwroot/cgi-bin/plugins/example/* wwwroot/css wwwroot/js tools/xslt
+DEB_INSTALL_EXAMPLES_awstats = $(awstats_example_scripts) debian/examples/awstats.default.conf debian/examples/apache.conf wwwroot/cgi-bin/awstats.model.conf wwwroot/cgi-bin/plugins/example/* wwwroot/css wwwroot/js tools/xslt
 DEB_COMPRESS_EXCLUDE = $(notdir $(awstats_example_scripts)) awstats.ico
 
 JAVA_HOME = /usr/lib/jvm/default-java
diff --git a/debian/update.sh b/debian/update.sh
index 2dcf647..904f59b 100755
--- a/debian/update.sh
+++ b/debian/update.sh
@@ -17,8 +17,7 @@ NICE=${AWSTATS_NICE:-10}
 cd /etc/awstats
 
 TMPFILE=`mktemp /tmp/awstats.XXXXXXXXXX`
-for c in awstats \
-         `/bin/ls -1 awstats.*.conf 2>/dev/null | \
+for c in `/bin/ls -1 awstats.*.conf 2>/dev/null | \
           /bin/sed 's/^awstats\.\(.*\)\.conf/\1/'`
 do
   if ! nice -n $NICE $AWSTATS -config=$c -update >$TMPFILE 2>&1; then
-- 
1.5.6.5

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0006-debian-update.sh
Type: text/x-shellscript
Size: 623 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-awstats-devel/attachments/20100507/353e3153/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0006-debian-buildstatic.sh
Type: text/x-shellscript
Size: 1019 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-awstats-devel/attachments/20100507/353e3153/attachment-0003.bin>
-------------- next part --------------
awstats for Debian
==================

Quick'n'dirty setup
-------------------

Do the following for a simple setup of a single website with Apache 2.x:

  * Edit /etc/logrotate.d/apache2 to permit www-data access to logfiles
  * copy /usr/share/doc/awstats/examples/apache.conf to /etc/apache2/conf.d/
  * copy /usr/share/doc/awstats/examples/awstats.default.conf to /etc/awstats/
  * edit /etc/default/awstats to enable nightly build of static html reports

The above is _NOT_ supported or recommended! Please read the rest of this
document instead...


No stats are generated
----------------------

As AWStats is used both as a CGI-script and offline, it is by default run as
uid=www-data in cron jobs so that generated files are accessible from CGI as
well.
By default Apache stores (since version 1.3.22-1) logfiles with uid=root and
gid=adm, so you need to either...

 1) Change the rights of the logfiles in /etc/logrotate.d/apache2 so that
    www-data has at least read access.

 2) As 1) but change to a specific user, and use the suEXEC feature of Apache
    to run as same user (and either change the right of /var/lib/awstats as
    well or use another directory). This is more complicated, but then the logs
    are not generally accessible to the server (which was probably the point of
    the Apache default).

 3) Change awstats.pl to group adm (but beware that you are then taking the
    risk of allowing a CGI-script access to admin stuff on the machine!).

With other webservers than Apache several things should probably be
changed, like location and format of logfiles.


A few minutes is lost each day/week/month
-----------------------------------------

By default AWStats scans logfiles each 10 minutes. When Apache (and
other webservers) rotate their logfiles, the last entries in the old
logfile may not have been read by AWStats.

Make sure to run AWStats right _before_ web logs are rotated (add a
"prerotate" in /etc/logrotate.d/apache2 for Apache).


The icons are missing
---------------------

You should redirect requests for /awstats-icon/ to
/usr/share/awstats/icon/.

In Apache, this is done by adding the following to
/etc/apache2/httpd.conf:

    Alias /awstats-icon/ /usr/share/awstats/icon/

For other webservers you should either do something similar, or make a
symlink from /var/www/awstats-icon to /usr/share/awstats/icon/.


Multiple stats
--------------

To handle multiple stats (for example, using VirtualHosts in Apache)
you should place all your configuration files under /etc/awstats/.
Name the files "awstats." + whatever you want + ".conf" (for example,
"awstats.example.com.conf").  But avoid "awstats.awstats.conf".

To retain use of a common config file containing defaults for all of
your sites, consider a scheme such as the following:

  Make a bunch of awstats.[site_name_here].conf files, and have the
  first line include the parent awstats.conf file (which by default
  also includes awstats.conf.local). The remainder of the file should
  have your site-specific configuration settings, which override the
  defaults specified in awstats.conf and awstats.conf.local.

  Here is an example of an awstats.example.com.conf file (of course,
  tailor the file for your own configuration):

        Include "awstats.conf"
        SiteDomain="example.com"
        HostAliases="example.com www.example.com"
        DirData="/var/lib/awstats/example.com"
        LogFile="/var/log/apache2/example.com_access_log"

  This way you can leave awstats.conf alone, and put your
  server-specific settings into awstats.conf.local, and your
  site-specific settings into each awstats.[site_name_here].conf file.

Note that the awstats package cannot safely handle upgrades to locally
added config files -- if config options change then the main file is
updated (with warnings if edited locally), but extra config files are
silently ignored and possibly broken.


Browser and referer stats are missing
-------------------------------------

Check, if the logfile has needed info about browser types and referer.
It is recommended to use "combined" logfiles format (Apache in Debian
uses one by default).


Where is configure.pl?
----------------------

AWStats configure.pl script is not available as a CGI script on
Debian.  Instead, it is located as awstats_configure.pl in
/usr/share/doc/awstats/examples/.

 -- Jonas Smedegaard <dr at jones.dk>  Fri,  8 Oct 2004 12:28:31 +0200
-------------- next part --------------
# This is a sample site-specific configuration file for AWStats.  You
# can copy it into /etc/awstats/ and rename it according to your site
# name.  Also change the SiteDomain parameter below to your site name
# and add any additional configuration parameters that you wish to
# override (see /etc/awstats/awstats.conf for a list of parameters).

# You may create several copies of this file with different names for
# multiple virtual hosts.  To set defaults for all of your sites, it
# is recommended that you place your changes in
# /etc/awstats/awstats.conf.local and leave awstats.conf as it is.

# Note that when a variable is defined both in a config file and in an
# included file, AWStats will use the last value read for parameters that
# contains one value and AWStats will concat all values from both files for
# parameters that are lists of values.
#
Include "/etc/awstats/awstats.conf"

# "SiteDomain" must contain the main domain name, or the main intranet web
# server name, used to reach the web site.
# If you share the same log file for several virtual web servers, this
# parameter is used to tell AWStats to filter record that contains records for
# this virtual host name only (So check that this virtual hostname can be
# found in your log file and use a personalized log format that include the
# %virtualname tag).
# But for multi hosting a better solution is to have one log file for each
# virtual web server. In this case, this parameter is only used to generate
# full URL's links when ShowLinksOnUrl option is set to 1.
# If analyzing mail log, enter here the domain name of mail server.
# Example: "myintranetserver"
# Example: "www.domain.com"
# Example: "ftp.domain.com"
# Example: "domain.com"
#
SiteDomain="localhost"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0006-debian-rules
Type: text/x-pascal
Size: 4933 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-awstats-devel/attachments/20100507/353e3153/attachment-0001.pas>


More information about the Pkg-awstats-devel mailing list