Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 54 lines (43 sloc) 1.22 KB
#!/bin/bash
set -eux
shopt -s nullglob
cd $(dirname "$0")
BASE=$(pwd)
CONFIGDIR=$BASE/cgi-bin
DATADIR=$BASE/data
mkdir -p $DATADIR
function write_config {
cat > $CONFIG_PATH <<ENDCONFIG
DirData="$DATADIR"
Include "$BASE/awstats.common.conf"
LogFile="$1"
SiteDomain="$SITE"
HostAliases="www.$SITE"
UseHTTPSLinkForUrl="$HTTPSLINKS"
ENDCONFIG
if [[ -f $LOCAL_CONFIG_PATH ]]
then
cat $LOCAL_CONFIG_PATH >> $CONFIG_PATH
fi
}
for LOG in $(find $HOME/logs/*/http{s,}/access.log -mtime -31)
do
[[ "$LOG" =~ logs/(.+)/(http|https) ]]
SITE=${BASH_REMATCH[1]}
PROTOCOL=${BASH_REMATCH[2]}
case $PROTOCOL in
https) CONFIG=${SITE} ; HTTPSLINKS='/' ;;
*) CONFIG=${SITE}-${PROTOCOL} ; HTTPSLINKS='' ;;
esac
CONFIG_PATH=$CONFIGDIR/awstats.$CONFIG.conf
LOCAL_CONFIG_PATH=$BASE/awstats.$CONFIG.conf
LOGALLCMD="cd $HOME/logs/$SITE/$PROTOCOL && zcat -f access.log.2* access.log |"
LOGDAYCMD="cd $HOME/logs/$SITE/$PROTOCOL && cat access.log.0 access.log |"
case ${1:-all} in
all) write_config "$LOGALLCMD" ;;
day) write_config "$LOGDAYCMD" ;;
esac
$BASE/awstats/wwwroot/cgi-bin/awstats.pl -configdir=$CONFIGDIR -config=$CONFIG -update
# Rewrite config with all logs to better support rawlog searches
write_config "$LOGALLCMD"
done
You can’t perform that action at this time.