Skip to content

Commit fb0a429

Browse files
committed
#1 add script hooks
1 parent bf50031 commit fb0a429

File tree

5 files changed

+34
-1
lines changed

5 files changed

+34
-1
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ jobs:
2525
username: ${{ secrets.DOCKER_USERNAME }}
2626
password: ${{ secrets.DOCKER_PASSWORD }}
2727
repository: justb4/awstats
28-
tags: latest,7.6-1
28+
tags: latest,7.6-2
2929
tag_with_ref: false
3030
tag_with_sha: true

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ RUN \
1515
&& apt-get -yy install awstats gettext-base libapache2-mod-perl2 ${GEOIP_PACKAGES} supervisor cron \
1616
&& echo 'Include conf/awstats_httpd.conf' >> /usr/local/apache2/conf/httpd.conf \
1717
&& mkdir /var/www && mv /usr/share/awstats/icon /var/www/icons && chown -R www-data:www-data /var/www \
18+
&& mkdir -p /aw-setup.d && mkdir -p /aw-update.d \
1819
&& apt-get clean && rm -rf /var/cache/apk/* /tmp/* /var/tmp/*
1920

2021
# Configurations, some are templates to be substituted with env vars

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
README
22
======
33

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

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

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

90+
User-defined Scripts
91+
--------------------
92+
93+
User-defined Shell/Bash scripts can be added in the directories `/aw-setup.d` and/or `/aw-update.d` by extending
94+
the Docker Image or easier via Docker Volume Mounting.
95+
96+
Purpose is to provide hooks for preprocessing. For example, a script that fetches/syncs a logfile from a remote
97+
server just before [aw-update.sh](scripts/aw-update.sh) runs. This ensures the data is available.
98+
8399
Analyze old log files
84100
---------------------
85101

scripts/aw-setup.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44

55
echo "START aw-setup"
66

7+
echo "Running one-time provisioning"
8+
for f in /aw-setup.d/*
9+
do
10+
case "$f" in
11+
*/*.sh) echo "$0: running $f" && . "$f" ;;
12+
esac
13+
done
14+
715
INDEX_HTML=/var/www/index.html
816

917
pushd ${AWSTATS_SITES_DIR}

scripts/aw-update.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44

55
echo "START aw-update"
66

7+
echo "Running additional provisioning"
8+
for f in /aw-update.d/*
9+
do
10+
case "$f" in
11+
*/*.sh) echo "$0: running $f" && . "$f" ;;
12+
esac
13+
done
14+
715
pushd /etc/awstats
816
for SITE_CONF in $(ls awstats.*.conf)
917
do

0 commit comments

Comments
 (0)