Skip to content

Commit

Permalink
#1 add script hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
justb4 committed Oct 12, 2020
1 parent bf50031 commit fb0a429
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: justb4/awstats
tags: latest,7.6-1
tags: latest,7.6-2
tag_with_ref: false
tag_with_sha: true
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ RUN \
&& apt-get -yy install awstats gettext-base libapache2-mod-perl2 ${GEOIP_PACKAGES} supervisor cron \
&& echo 'Include conf/awstats_httpd.conf' >> /usr/local/apache2/conf/httpd.conf \
&& mkdir /var/www && mv /usr/share/awstats/icon /var/www/icons && chown -R www-data:www-data /var/www \
&& mkdir -p /aw-setup.d && mkdir -p /aw-update.d \
&& apt-get clean && rm -rf /var/cache/apk/* /tmp/* /var/tmp/*

# Configurations, some are templates to be substituted with env vars
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
README
======


![GitHub license](https://img.shields.io/github/license/justb4/docker-awstats)
![GitHub release](https://img.shields.io/github/release/justb4/docker-awstats.svg)
![Docker Pulls](https://img.shields.io/docker/pulls/justb4/awstats.svg)

All-in-one [Awstats](http://www.awstats.org) Docker Image for scheduled log-processing on multiple domains with minimal config, accessible
via built-in webpage. Find [built Docker Images on Docker Hub](https://hub.docker.com/repository/docker/justb4/awstats).
NB some links below refer to relative files on GitHub, read [full/latest README here](https://github.com/justb4/docker-awstats).
Expand All @@ -17,6 +22,8 @@ Features
* landing HTML page for all configured sites
* configurable `subpath` (prefix) for running behind reverse proxy
* easy run with [docker-compose](test/docker-compose.yml)
* run user-defined scripts once before startup (`aw-setup.sh`)
* run user-defined scripts before each scheduled `awstats` run (`aw-update.sh`), e.g. for log file sync

The aim was to make this image as self-contained as possible with minimal host-dependencies.

Expand Down Expand Up @@ -80,6 +87,15 @@ The entry program is `supervisord` that will run a [setup program once](scripts/
Advanced
========

User-defined Scripts
--------------------

User-defined Shell/Bash scripts can be added in the directories `/aw-setup.d` and/or `/aw-update.d` by extending
the Docker Image or easier via Docker Volume Mounting.

Purpose is to provide hooks for preprocessing. For example, a script that fetches/syncs a logfile from a remote
server just before [aw-update.sh](scripts/aw-update.sh) runs. This ensures the data is available.

Analyze old log files
---------------------

Expand Down
8 changes: 8 additions & 0 deletions scripts/aw-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

echo "START aw-setup"

echo "Running one-time provisioning"
for f in /aw-setup.d/*
do
case "$f" in
*/*.sh) echo "$0: running $f" && . "$f" ;;
esac
done

INDEX_HTML=/var/www/index.html

pushd ${AWSTATS_SITES_DIR}
Expand Down
8 changes: 8 additions & 0 deletions scripts/aw-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

echo "START aw-update"

echo "Running additional provisioning"
for f in /aw-update.d/*
do
case "$f" in
*/*.sh) echo "$0: running $f" && . "$f" ;;
esac
done

pushd /etc/awstats
for SITE_CONF in $(ls awstats.*.conf)
do
Expand Down

0 comments on commit fb0a429

Please sign in to comment.