blob: 9b727d89812a32c95fb06cbc52ae757d0f84a563 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#! /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}"
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="${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"
|