summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Spragg <adam@spragg-ssl.co.uk>2018-08-13 12:46:03 +0100
committerAdam Spragg <adam@spragg-ssl.co.uk>2018-08-13 12:46:03 +0100
commit712270c13b74f3f08ea07d9e9d71c1f890d88ed2 (patch)
treed54eeb404edc5695e2db9f78c6d8295c1369a7d3
parenta43b5b6a5d1e1b88b7959427478b65ddbb931c35 (diff)
Store stats pages in per-month directories
So I have access to old stats
-rwxr-xr-xdaily.sh13
1 files changed, 11 insertions, 2 deletions
diff --git a/daily.sh b/daily.sh
index 81961e7..9b727d8 100755
--- a/daily.sh
+++ b/daily.sh
@@ -17,15 +17,24 @@ AWMON=`/bin/date -d yesterday +%m`
# 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"
+AWHTML="${SITEROOT}/awstats/html/${AWYEAR}-${AWMON}"
+
+# Remove any PII (i.e. IP addresses) from the awstats data
/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}"
+# Ensure the destination directory for the relevant month exists
+/bin/mkdir -p "${AWHTML}"
+
+# Build the stats pages
/usr/share/awstats/tools/awstats_buildstaticpages.pl \
-awstatsprog="${SITEROOT}/awstats/awstats" \
- -config="${DOMAIN}" -dir="${SITEROOT}/awstats/html" \
+ -config="${DOMAIN}" -dir="${AWHTML}" \
-year="${AWYEAR}" -month="${AWMON}" \
2>&1 | /usr/bin/ts "${TSFMT} awstats_buildstaticpages.pl:" >>"${LOGFILE}"
+# Add an index.html symlink (why doesn't it do this itself already?)
+/bin/ln -s -f "awstats.${DOMAIN}.html" "${AWHTML}/index.html"
+