From cf333f189d573132288370e4e9d0b5fdb66eb3ff Mon Sep 17 00:00:00 2001 From: Ken Neighbors 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 +## buildstatic.sh, written by Sergey B Kirpichev ## ## 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 +## update.sh, written by Sergey B Kirpichev ## ## 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