#!/bin/sh 
CONF_DIR="/etc/awstats"
CONF_EXT="conf"
AWSTATS="/usr/lib/cgi-bin/awstats.pl "

if [ ! -d "$CONF_DIR" ]; then
  echo "$CONF_DIR does not exist"
  exit 1
else
  cd $CONF_DIR
fi

/usr/sbin/apache2ctl graceful >/dev/null

for cfg in *.$CONF_EXT; do
if [ "$cfg" != "awstats.model.conf" ]; then

   SITE=`echo $cfg | sed -e "s/awstats\.\(.*\)\.$CONF_EXT/\1/g"` 
   TARGET="/home/services/awstats/$SITE/html"
   $AWSTATS -update -site="$SITE" -config="$SITE" > /dev/null
   $AWSTATS -config="$SITE" -output -staticlinks -lang=hu > $TARGET/index.html
    for detail in allhosts lasthosts unknownip urldetail unknownreferer unknownrefererbrowser browserdetail allkeyphrases errors404; do
	$AWSTATS -output=$detail -staticlinks -lang=hu -config="$SITE" > $TARGET/awstats.$detail.html
    done
fi
done

