[Pkg-awstats-devel] Bug#580704: awstats: Cosmetic improvements to cron scripts (update.sh and buildstatic.sh)
Ken Neighbors
debian3 at ken.nsds.com
Fri May 7 21:11:03 UTC 2010
Package: awstats
Version: 6.9.5~dfsg-2
Severity: wishlist
Tags: patch
These are some miscellaneous changes I made to the cron scripts.
Please feel free to take or leave any of these changes.
I used a different method to initialize the values read from
/etc/default/awstats (again with inspiration from /etc/init.d/rsync and
other init files). Specifically, instead of:
[ -r "$DEFAULT" ] && . "$DEFAULT"
-NICE=${AWSTATS_NICE:-10}
I did this:
AWSTATS_NICE=10
[ -r "$DEFAULT" ] && . "$DEFAULT"
This method reduces the need for another environment variable ("NICE")
because it can use the existing environment variable ("AWSTATS_NICE")
defined in /etc/default/awstats (similarly for "AWSTATS_LANG" and
"AWSTATS_ENABLE_BUILDSTATICPAGES").
I moved AWSTATS_LANG, Y, and m (the date calls) out of the
buildstatic.sh loop since they should remain constant for all config files.
I used an alternate method to extract the config file name using posix
shell parameter expansions (without calling the external programs ls and
sed).
Note: the included patch was generated in comparison to the resulting
files from my previous patches.
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
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=580699
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=580702
For the convenience of the maintainers of this package, I have
attached a patch file incorporating all the changes I submitted today
(using "git format-patch") and a couple additional bug fixes I
submitted earlier. Please feel free to take any of the patches or
give me some feedback if you'd like something done differently. I
hope this is helpful, and I really appreciate the work the awstats
Debian team has put into maintaining this package.
-- 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 cf333f189d573132288370e4e9d0b5fdb66eb3ff Mon Sep 17 00:00:00 2001
From: Ken Neighbors <ken at nsds.com>
Date: Tue, 27 Apr 2010 15:28:21 -0700
Subject: Cosmetic improvements to cron scripts (update.sh and buildstatic.sh).
---
debian/buildstatic.sh | 32 ++++++++++++++++++--------------
debian/update.sh | 14 ++++++++------
2 files changed, 26 insertions(+), 20 deletions(-)
diff --git a/debian/buildstatic.sh b/debian/buildstatic.sh
index a0ec26a..0e41700 100755
--- a/debian/buildstatic.sh
+++ b/debian/buildstatic.sh
@@ -1,6 +1,6 @@
#!/bin/sh
##
-## buildstatic.sh, written by Sergey B Kirpichev <skirpichev at gmail.com>
+## buildstatic.sh, written by Sergey B Kirpichev <skirpichev at gmail.com>
##
## Build all static html reports from AWStats data (Debian specific)
##
@@ -11,31 +11,35 @@ DEFAULT=/etc/default/awstats
AWSTATS=/usr/lib/cgi-bin/awstats.pl
BUILDSTATICPAGES=/usr/share/awstats/tools/awstats_buildstaticpages.pl
+# Set defaults.
+AWSTATS_NICE=10
+AWSTATS_ENABLE_BUILDSTATICPAGES="no"
+AWSTATS_LANG="en"
+
[ -f $AWSTATS -a -f $BUILDSTATICPAGES ] || exit 1
[ -r "$DEFAULT" ] && . "$DEFAULT"
-NICE=${AWSTATS_NICE:-10}
-ENABLE=${AWSTATS_ENABLE_BUILDSTATICPAGES:-no}
-if [ "$ENABLE" != "yes" ]; then
+if [ "$AWSTATS_ENABLE_BUILDSTATICPAGES" != "yes" ]; then
exit 0
fi
+Y=`date +%Y`
+m=`date +%m`
+
cd /etc/awstats
TMPFILE=`mktemp /tmp/awstats.XXXXXXXXXX`
-for c in `/bin/ls -1 awstats.*.conf 2>/dev/null | \
- /bin/sed 's/^awstats\.\(.*\)\.conf/\1/'`
-do
- Y=`date +%Y`
- m=`date +%m`
+for c in awstats.*.conf; do
+ c=${c#awstats.} # remove prefix
+ c=${c%.conf} # remove suffix
mkdir -p /var/cache/awstats/$c/$Y/$m/
- AL=${AWSTATS_LANG:-en}
- if ! nice -n $NICE $BUILDSTATICPAGES \
- -config=$c \
+ if ! nice -n $AWSTATS_NICE $BUILDSTATICPAGES \
+ -config=$c \
-year=$Y \
-month=$m \
- -lang=$AL \
- -staticlinksext=${AL}.html \
+ -lang=$AWSTATS_LANG \
+ -staticlinksext=${AWSTATS_LANG}.html \
+ -awstatsprog=$AWSTATS \
-dir=/var/cache/awstats/$c/$Y/$m/ >$TMPFILE 2>&1
then
# an error occurred
diff --git a/debian/update.sh b/debian/update.sh
index 904f59b..fff3ab6 100755
--- a/debian/update.sh
+++ b/debian/update.sh
@@ -1,6 +1,6 @@
#!/bin/sh
##
-## update.sh, written by Sergey B Kirpchev <skirpichev at gmail.com>
+## update.sh, written by Sergey B Kirpichev <skirpichev at gmail.com>
##
## Update AWStats data for all configs, awstats.*.conf (Debian specific)
##
@@ -10,17 +10,19 @@ set -e
DEFAULT=/etc/default/awstats
AWSTATS=/usr/lib/cgi-bin/awstats.pl
+# Set defaults.
+AWSTATS_NICE=10
+
[ -f $AWSTATS ] || exit 1
[ -r "$DEFAULT" ] && . "$DEFAULT"
-NICE=${AWSTATS_NICE:-10}
cd /etc/awstats
TMPFILE=`mktemp /tmp/awstats.XXXXXXXXXX`
-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
+for c in awstats.*.conf; do
+ c=${c#awstats.} # remove prefix
+ c=${c%.conf} # remove suffix
+ if ! nice -n $AWSTATS_NICE $AWSTATS -config=$c -update >$TMPFILE 2>&1; then
# an error occurred
cat $TMPFILE >&2
fi
--
1.5.6.5
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0008-debian-update.sh
Type: text/x-shellscript
Size: 630 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-awstats-devel/attachments/20100507/c3a9e455/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0008-debian-buildstatic.sh
Type: text/x-shellscript
Size: 1072 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-awstats-devel/attachments/20100507/c3a9e455/attachment-0003.bin>
-------------- next part --------------
>From 846a6c9606c180815f40e5b91fdb7135ae3f81fe Mon Sep 17 00:00:00 2001
From: Ken Neighbors <ken at nsds.com>
Date: Thu, 29 Apr 2010 14:12:49 -0700
Subject: Add patch to report error when config file exists but cannot be read.
Closes: #572353, thanks to Ken Neighbors.
---
debian/patches/1015_config_read_error.patch | 26 ++++++++++++++++++++++++++
debian/patches/series | 1 +
2 files changed, 27 insertions(+), 0 deletions(-)
create mode 100644 debian/patches/1015_config_read_error.patch
diff --git a/debian/patches/1015_config_read_error.patch b/debian/patches/1015_config_read_error.patch
new file mode 100644
index 0000000..be08c20
--- /dev/null
+++ b/debian/patches/1015_config_read_error.patch
@@ -0,0 +1,26 @@
+Description: Report error when config file exists but cannot be read.
+Author: Ken Neighbors <ken at nsds.com>
+Bug-Debian: http://bugs.debian.org/572353
+
+Index: awstats/wwwroot/cgi-bin/awstats.pl
+===================================================================
+--- awstats.orig/wwwroot/cgi-bin/awstats.pl 2007-07-07 11:00:06.000000000 +0000
++++ awstats/wwwroot/cgi-bin/awstats.pl 2010-04-29 20:34:08.000000000 +0000
+@@ -1742,11 +1742,17 @@
+ $FileSuffix = ".$SiteConfig";
+ last;
+ }
++ elsif ( -e "$searchdir$PROG.$SiteConfig.conf" ) {
++ error("Couldn't open config file \"$searchdir$PROG.$SiteConfig.conf\": $!" );
++ }
+ if ( open( CONFIG, "$searchdir$PROG.conf" ) ) {
+ $FileConfig = "$searchdir$PROG.conf";
+ $FileSuffix = '';
+ last;
+ }
++ elsif ( -e "$searchdir$PROG.conf" ) {
++ error("Couldn't open config file \"$searchdir$PROG.conf\": $!" );
++ }
+ }
+ if ( !$FileConfig ) {
+ error(
diff --git a/debian/patches/series b/debian/patches/series
index 88bb06f..ec29f1c 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -10,4 +10,5 @@
1012_ipv6_strip_trailing_dot.patch
1013_yahoo_search.patch
1014_websec_robot.patch
+1015_config_read_error.patch
2001_awstatsprog_path.patch
--
1.5.6.5
>From 641feeb2ac32ef72c4faf4546154b96e3af488b8 Mon Sep 17 00:00:00 2001
From: Ken Neighbors <ken at nsds.com>
Date: Thu, 29 Apr 2010 14:01:39 -0700
Subject: Add patch to fix truncated nested included config files.
Closes: #575545, thanks to Ken Neighbors.
---
debian/patches/1016_nested_includes.patch | 28 ++++++++++++++++++++++++++++
debian/patches/series | 1 +
2 files changed, 29 insertions(+), 0 deletions(-)
create mode 100644 debian/patches/1016_nested_includes.patch
diff --git a/debian/patches/1016_nested_includes.patch b/debian/patches/1016_nested_includes.patch
new file mode 100644
index 0000000..80449f9
--- /dev/null
+++ b/debian/patches/1016_nested_includes.patch
@@ -0,0 +1,28 @@
+Description: Fix bug with truncated nested included config files.
+Author: Ken Neighbors <ken at nsds.com>
+Bug-Debian: http://bugs.debian.org/575545
+
+Index: awstats/wwwroot/cgi-bin/awstats.pl
+===================================================================
+--- awstats.orig/wwwroot/cgi-bin/awstats.pl 2007-07-07 11:00:06.000000000 +0000
++++ awstats/wwwroot/cgi-bin/awstats.pl 2010-03-26 16:54:32.000000000 +0000
+@@ -1220,6 +1220,7 @@
+ );
+ next;
+ }
++ local( *CONFIG_INCLUDE );
+ if ( open( CONFIG_INCLUDE, $includeFile ) ) {
+ &Parse_Config( *CONFIG_INCLUDE, $level + 1, $includeFile );
+ close(CONFIG_INCLUDE);
+Index: awstats/tools/awstats_buildstaticpages.pl
+===================================================================
+--- awstats.orig/tools/awstats_buildstaticpages.pl 2007-07-07 10:57:20.000000000 +0000
++++ awstats/tools/awstats_buildstaticpages.pl 2010-03-26 19:11:57.000000000 +0000
+@@ -189,6 +189,7 @@
+ warning("Warning: Perl versions before 5.6 cannot handle nested includes");
+ next;
+ }
++ local( *CONFIG_INCLUDE );
+ if ( open( CONFIG_INCLUDE, $includeFile ) ) {
+ &Parse_Config( *CONFIG_INCLUDE , $level+1, $includeFile);
+ close( CONFIG_INCLUDE );
diff --git a/debian/patches/series b/debian/patches/series
index 88bb06f..00ddf4e 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -10,4 +10,5 @@
1012_ipv6_strip_trailing_dot.patch
1013_yahoo_search.patch
1014_websec_robot.patch
+1016_nested_includes.patch
2001_awstatsprog_path.patch
--
1.5.6.5
>From cf0fa60b4d7279d6dc3deae071a0ff9555823e40 Mon Sep 17 00:00:00 2001
From: Ken Neighbors <ken at nsds.com>
Date: Wed, 28 Apr 2010 09:54:58 -0700
Subject: Show error messages from cron jobs (update.sh and buildstatic.sh).
---
debian/buildstatic.sh | 12 +++++++++---
debian/update.sh | 9 +++++++--
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/debian/buildstatic.sh b/debian/buildstatic.sh
index 91dd4d9..9f41cbc 100755
--- a/debian/buildstatic.sh
+++ b/debian/buildstatic.sh
@@ -16,6 +16,7 @@ BUILDSTATICPAGES=/usr/share/awstats/tools/awstats_buildstaticpages.pl
cd /etc/awstats
+TMPFILE=`mktemp /tmp/awstats.XXXXXXXXXX`
for c in awstats \
`/bin/ls -1 awstats.*.conf 2>/dev/null | \
/bin/sed 's/^awstats\.\(.*\)\.conf/\1/'`
@@ -24,11 +25,16 @@ do
m=`date +%m`
mkdir -p /var/cache/awstats/$c/$Y/$m/
AL=${AWSTATS_LANG:-en}
- $BUILDSTATICPAGES \
+ if ! $BUILDSTATICPAGES \
-config=$c \
-year=$Y \
-month=$m \
-lang=$AL \
-staticlinksext=${AL}.html \
- -dir=/var/cache/awstats/$c/$Y/$m/
-done >/dev/null
+ -dir=/var/cache/awstats/$c/$Y/$m/ >$TMPFILE 2>&1
+ then
+ # an error occurred
+ cat $TMPFILE >&2
+ fi
+done
+rm -f $TMPFILE
diff --git a/debian/update.sh b/debian/update.sh
index bd49d5d..11a8e03 100755
--- a/debian/update.sh
+++ b/debian/update.sh
@@ -14,9 +14,14 @@ AWSTATS=/usr/lib/cgi-bin/awstats.pl
cd /etc/awstats
+TMPFILE=`mktemp /tmp/awstats.XXXXXXXXXX`
for c in awstats \
`/bin/ls -1 awstats.*.conf 2>/dev/null | \
/bin/sed 's/^awstats\.\(.*\)\.conf/\1/'`
do
- $AWSTATS -config=$c -update
-done >/dev/null
+ if ! $AWSTATS -config=$c -update >$TMPFILE 2>&1; then
+ # an error occurred
+ cat $TMPFILE >&2
+ fi
+done
+rm -f $TMPFILE
--
1.5.6.5
>From 3492ee4e32a1dd2cafa982c6603b7f8afe14564d Mon Sep 17 00:00:00 2001
From: Ken Neighbors <ken at nsds.com>
Date: Wed, 28 Apr 2010 22:31:40 -0700
Subject: Add option to disable nightly generation of static html reports.
---
debian/README.Debian | 1 +
debian/buildstatic.sh | 5 +++++
debian/default/awstats | 4 ++++
3 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/debian/README.Debian b/debian/README.Debian
index d5a9a1e..ed8b69f 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/
+ * 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...
diff --git a/debian/buildstatic.sh b/debian/buildstatic.sh
index 9f41cbc..ca09cc7 100755
--- a/debian/buildstatic.sh
+++ b/debian/buildstatic.sh
@@ -14,6 +14,11 @@ BUILDSTATICPAGES=/usr/share/awstats/tools/awstats_buildstaticpages.pl
[ -f $AWSTATS -a -f $BUILDSTATICPAGES ] || exit 1
[ -r "$DEFAULT" ] && . "$DEFAULT"
+ENABLE=${AWSTATS_ENABLE_BUILDSTATICPAGES:-no}
+if [ "$ENABLE" != "yes" ]; then
+ exit 0
+fi
+
cd /etc/awstats
TMPFILE=`mktemp /tmp/awstats.XXXXXXXXXX`
diff --git a/debian/default/awstats b/debian/default/awstats
index 3785ea3..d8830cc 100644
--- a/debian/default/awstats
+++ b/debian/default/awstats
@@ -1,5 +1,9 @@
# AWStats configuration options
+# This variable controls whether to create static html reports every
+# night in /var/cache/awstats/. Set to "yes" or "no".
+AWSTATS_ENABLE_BUILDSTATICPAGES="no"
+
# This variable control the language of all static html reports. Set
# one to appropriate two-letter language code (default to en).
#AWSTATS_LANG=ru
--
1.5.6.5
>From 31217b14bb2ca6b06797ee26adf6957e55b445dd Mon Sep 17 00:00:00 2001
From: Ken Neighbors <ken at nsds.com>
Date: Wed, 28 Apr 2010 22:34:27 -0700
Subject: Use "nice" to lower the priority of the AWStats processes when
updating databases and generating static html reports from cron.
---
debian/buildstatic.sh | 3 ++-
debian/default/awstats | 5 +++++
debian/update.sh | 4 +++-
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/debian/buildstatic.sh b/debian/buildstatic.sh
index ca09cc7..8af4c83 100755
--- a/debian/buildstatic.sh
+++ b/debian/buildstatic.sh
@@ -14,6 +14,7 @@ BUILDSTATICPAGES=/usr/share/awstats/tools/awstats_buildstaticpages.pl
[ -f $AWSTATS -a -f $BUILDSTATICPAGES ] || exit 1
[ -r "$DEFAULT" ] && . "$DEFAULT"
+NICE=${AWSTATS_NICE:-10}
ENABLE=${AWSTATS_ENABLE_BUILDSTATICPAGES:-no}
if [ "$ENABLE" != "yes" ]; then
exit 0
@@ -30,7 +31,7 @@ do
m=`date +%m`
mkdir -p /var/cache/awstats/$c/$Y/$m/
AL=${AWSTATS_LANG:-en}
- if ! $BUILDSTATICPAGES \
+ if ! nice -n $NICE $BUILDSTATICPAGES \
-config=$c \
-year=$Y \
-month=$m \
diff --git a/debian/default/awstats b/debian/default/awstats
index d8830cc..ac8c320 100644
--- a/debian/default/awstats
+++ b/debian/default/awstats
@@ -1,5 +1,10 @@
# AWStats configuration options
+# This variable controls the scheduling priority for updating AWStats
+# datafiles and for generating static html reports. Normal priority
+# is 0 and a lower priority is 10. See "man nice" for more info.
+AWSTATS_NICE=10
+
# This variable controls whether to create static html reports every
# night in /var/cache/awstats/. Set to "yes" or "no".
AWSTATS_ENABLE_BUILDSTATICPAGES="no"
diff --git a/debian/update.sh b/debian/update.sh
index 11a8e03..2dcf647 100755
--- a/debian/update.sh
+++ b/debian/update.sh
@@ -11,6 +11,8 @@ DEFAULT=/etc/default/awstats
AWSTATS=/usr/lib/cgi-bin/awstats.pl
[ -f $AWSTATS ] || exit 1
+[ -r "$DEFAULT" ] && . "$DEFAULT"
+NICE=${AWSTATS_NICE:-10}
cd /etc/awstats
@@ -19,7 +21,7 @@ for c in awstats \
`/bin/ls -1 awstats.*.conf 2>/dev/null | \
/bin/sed 's/^awstats\.\(.*\)\.conf/\1/'`
do
- if ! $AWSTATS -config=$c -update >$TMPFILE 2>&1; then
+ if ! nice -n $NICE $AWSTATS -config=$c -update >$TMPFILE 2>&1; then
# an error occurred
cat $TMPFILE >&2
fi
--
1.5.6.5
>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
>From 9ec6cd3775c74ec57ab2474b6a347b05fbe88f98 Mon Sep 17 00:00:00 2001
From: Ken Neighbors <ken at nsds.com>
Date: Tue, 27 Apr 2010 15:05:12 -0700
Subject: Improve documentation of logfile permissions and suggest
EnableLockForUpdate=1.
---
debian/README.Debian | 31 ++++++++++++++++++++++---------
1 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/debian/README.Debian b/debian/README.Debian
index b3ea45b..94fff06 100644
--- a/debian/README.Debian
+++ b/debian/README.Debian
@@ -7,16 +7,16 @@ 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
+ * 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
-----------------------
+No stats are generated due to logfile permissions
+-------------------------------------------------
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
@@ -24,8 +24,10 @@ 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.
+ 1) Change the rights of the logfiles so that www-data has at least read
+ access. For example:
+ change line in /etc/logrotate.d/apache2 to: "create 644 root adm"
+ change permissions of existing files: chmod 644 /var/log/apache2/*.log
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
@@ -47,8 +49,19 @@ 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).
+Make sure to run AWStats right _before_ web logs are rotated. For
+example, insert the following lines in /etc/logrotate.d/apache2:
+
+ prerotate
+ if [ -x /usr/share/awstats/tools/update.sh ]; then
+ su - -c /usr/share/awstats/tools/update.sh www-data
+ fi
+ endscript
+
+Also consider enabling lock files in /etc/awstats/awstats.conf.local
+with EnableLockForUpdate=1 so that only one AWStats update process is
+running at a time. This will reduce system resources especially if
+the AWStats update process takes longer than 10 minutes to complete.
The icons are missing
--
1.5.6.5
>From cf333f189d573132288370e4e9d0b5fdb66eb3ff Mon Sep 17 00:00:00 2001
From: Ken Neighbors <ken at nsds.com>
Date: Tue, 27 Apr 2010 15:28:21 -0700
Subject: Cosmetic improvements to cron scripts (update.sh and buildstatic.sh).
---
debian/buildstatic.sh | 32 ++++++++++++++++++--------------
debian/update.sh | 14 ++++++++------
2 files changed, 26 insertions(+), 20 deletions(-)
diff --git a/debian/buildstatic.sh b/debian/buildstatic.sh
index a0ec26a..0e41700 100755
--- a/debian/buildstatic.sh
+++ b/debian/buildstatic.sh
@@ -1,6 +1,6 @@
#!/bin/sh
##
-## buildstatic.sh, written by Sergey B Kirpichev <skirpichev at gmail.com>
+## buildstatic.sh, written by Sergey B Kirpichev <skirpichev at gmail.com>
##
## Build all static html reports from AWStats data (Debian specific)
##
@@ -11,31 +11,35 @@ DEFAULT=/etc/default/awstats
AWSTATS=/usr/lib/cgi-bin/awstats.pl
BUILDSTATICPAGES=/usr/share/awstats/tools/awstats_buildstaticpages.pl
+# Set defaults.
+AWSTATS_NICE=10
+AWSTATS_ENABLE_BUILDSTATICPAGES="no"
+AWSTATS_LANG="en"
+
[ -f $AWSTATS -a -f $BUILDSTATICPAGES ] || exit 1
[ -r "$DEFAULT" ] && . "$DEFAULT"
-NICE=${AWSTATS_NICE:-10}
-ENABLE=${AWSTATS_ENABLE_BUILDSTATICPAGES:-no}
-if [ "$ENABLE" != "yes" ]; then
+if [ "$AWSTATS_ENABLE_BUILDSTATICPAGES" != "yes" ]; then
exit 0
fi
+Y=`date +%Y`
+m=`date +%m`
+
cd /etc/awstats
TMPFILE=`mktemp /tmp/awstats.XXXXXXXXXX`
-for c in `/bin/ls -1 awstats.*.conf 2>/dev/null | \
- /bin/sed 's/^awstats\.\(.*\)\.conf/\1/'`
-do
- Y=`date +%Y`
- m=`date +%m`
+for c in awstats.*.conf; do
+ c=${c#awstats.} # remove prefix
+ c=${c%.conf} # remove suffix
mkdir -p /var/cache/awstats/$c/$Y/$m/
- AL=${AWSTATS_LANG:-en}
- if ! nice -n $NICE $BUILDSTATICPAGES \
- -config=$c \
+ if ! nice -n $AWSTATS_NICE $BUILDSTATICPAGES \
+ -config=$c \
-year=$Y \
-month=$m \
- -lang=$AL \
- -staticlinksext=${AL}.html \
+ -lang=$AWSTATS_LANG \
+ -staticlinksext=${AWSTATS_LANG}.html \
+ -awstatsprog=$AWSTATS \
-dir=/var/cache/awstats/$c/$Y/$m/ >$TMPFILE 2>&1
then
# an error occurred
diff --git a/debian/update.sh b/debian/update.sh
index 904f59b..fff3ab6 100755
--- a/debian/update.sh
+++ b/debian/update.sh
@@ -1,6 +1,6 @@
#!/bin/sh
##
-## update.sh, written by Sergey B Kirpchev <skirpichev at gmail.com>
+## update.sh, written by Sergey B Kirpichev <skirpichev at gmail.com>
##
## Update AWStats data for all configs, awstats.*.conf (Debian specific)
##
@@ -10,17 +10,19 @@ set -e
DEFAULT=/etc/default/awstats
AWSTATS=/usr/lib/cgi-bin/awstats.pl
+# Set defaults.
+AWSTATS_NICE=10
+
[ -f $AWSTATS ] || exit 1
[ -r "$DEFAULT" ] && . "$DEFAULT"
-NICE=${AWSTATS_NICE:-10}
cd /etc/awstats
TMPFILE=`mktemp /tmp/awstats.XXXXXXXXXX`
-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
+for c in awstats.*.conf; do
+ c=${c#awstats.} # remove prefix
+ c=${c%.conf} # remove suffix
+ if ! nice -n $AWSTATS_NICE $AWSTATS -config=$c -update >$TMPFILE 2>&1; then
# an error occurred
cat $TMPFILE >&2
fi
--
1.5.6.5
More information about the Pkg-awstats-devel
mailing list