#! /bin/sh DOMAIN="spragg-ssl.co.uk" SITEROOT="/srv/www/$DOMAIN" DATE=`/bin/date +%Y-%m-%d` LOGFILE="$SITEROOT/log/updates.$DATE.log" TSFMT="%b %d %H:%M:%S" AWYEAR=`/bin/date -d yesterday +%Y` AWMON=`/bin/date -d yesterday +%m` # Delete any logs older than 30 days /usr/bin/find "$SITEROOT/log" -name "*.log" -mtime +30 -delete 2>&1 | /usr/bin/ts "$TSFMT find:" >>$LOGFILE # Run awstats $SITEROOT/awstats/awstats -config="$DOMAIN" -update 2>&1 | /usr/bin/ts "$TSFMT awstats:" >>$LOGFILE # Remove any PII (i.e. IP addresses) from the awstats data AWDATA="$SITEROOT/awstats/data/awstats${AWMON}${AWYEAR}.txt" /bin/grep -E -v "^[[:digit:]]{1,3}\\.[[:digit:]]{1,3}\\.[[:digit:]]{1,3}\\.[[:digit:]]{1,3} [[:digit:]]" "$AWDATA" \ | /bin/sed -e "s/^BEGIN_VISITOR [[:digit:]]\\+\$/BEGIN_VISITOR 0/" \ | /usr/bin/sponge "$AWDATA" /usr/share/awstats/tools/awstats_buildstaticpages.pl \ -awstatsprog="$SITEROOT/awstats/awstats" \ -config="$DOMAIN" -dir="$SITEROOT/awstats/html" \ -year="$AWYEAR" -month="$AWMONTH" \ 2>&1 | /usr/bin/ts "$TSFMT awstats_buildstaticpages.pl:" >>$LOGFILE