From b8c4e51fbe9e2b542ff4d7986cdfc0d9bba46c61 Mon Sep 17 00:00:00 2001 From: paspo Date: Thu, 31 Jul 2025 15:43:47 +0200 Subject: [PATCH] FIX #4: added DISABLE_STATS flag and moved stats refresh in a dedicated script --- README.md | 1 + rootfs/app/entrypoint.sh | 2 ++ rootfs/app/entrypoint.sh.d/90_logs.sh | 2 +- rootfs/app/entrypoint.sh.d/90_stats.sh | 4 ++++ rootfs/app/stats.sh | 15 +++++++++++++++ 5 files changed, 23 insertions(+), 1 deletion(-) create mode 100755 rootfs/app/stats.sh diff --git a/README.md b/README.md index 38f8adb..bfbf676 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ services: FPM_MAX_SPARE_SERVERS: 3 # default: 3 DISABLE_WEBROOT_CHOWN: 1 # default: 0 DISABLE_SFTP: 1 # default: 0 + DISABLE_STATS: 1 # default: 0 ``` The `/data/www` and `/data/logs` directories and their contents will be chowned to `$PUID:$PGID` and chmodded to `0755` for directories and `0644` for files at container start. diff --git a/rootfs/app/entrypoint.sh b/rootfs/app/entrypoint.sh index c1edcb0..48da9b1 100755 --- a/rootfs/app/entrypoint.sh +++ b/rootfs/app/entrypoint.sh @@ -26,6 +26,7 @@ FPM_MAX_SPARE_SERVERS=${FPM_MAX_SPARE_SERVERS:-3} DISABLE_WEBROOT_CHOWN=${DISABLE_WEBROOT_CHOWN:-0} DISABLE_SFTP=${DISABLE_SFTP:-0} +DISABLE_STATS=${DISABLE_STATS:-0} export USERNAME export GROUPNAME @@ -51,6 +52,7 @@ export FPM_MAX_SPARE_SERVERS export DISABLE_WEBROOT_CHOWN export DISABLE_SFTP +export DISABLE_STATS # run all scripts in order run-parts /app/entrypoint.sh.d diff --git a/rootfs/app/entrypoint.sh.d/90_logs.sh b/rootfs/app/entrypoint.sh.d/90_logs.sh index 4ce60a3..8e98408 100755 --- a/rootfs/app/entrypoint.sh.d/90_logs.sh +++ b/rootfs/app/entrypoint.sh.d/90_logs.sh @@ -18,7 +18,7 @@ ${PATH_LOGS}/nginx-access.log { su ${USERNAME} ${GROUPNAME} postrotate /usr/sbin/nginx -s reopen - nice -n 19 /usr/bin/goaccess ${PATH_LOGS}/nginx-access.log.1 --agent-list --anonymize-ip --real-os --exclude-ip 127.0.0.1 --output ${PATH_STATS}/index.html --log-format COMBINED --tz="${TZ}" --db-path=${PATH_STATSDB} --persist --restore + nice -n 19 /app/stats.sh endscript } EOF diff --git a/rootfs/app/entrypoint.sh.d/90_stats.sh b/rootfs/app/entrypoint.sh.d/90_stats.sh index 3b01d48..b9717e1 100755 --- a/rootfs/app/entrypoint.sh.d/90_stats.sh +++ b/rootfs/app/entrypoint.sh.d/90_stats.sh @@ -1,5 +1,9 @@ #!/bin/sh +if [ ${DISABLE_STATS} -eq 1 ] ; then + exit 0 +fi + echo "# Configuring stats" # make sure paths exists diff --git a/rootfs/app/stats.sh b/rootfs/app/stats.sh new file mode 100755 index 0000000..35f9f90 --- /dev/null +++ b/rootfs/app/stats.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +if [ "${DISABLE_STATS:-0}" -eq 1 ] ; then + exit 0 +fi + +PATH_BASE=/data +PATH_STATS=${PATH_BASE}/stats +PATH_STATSDB=${PATH_BASE}/stats.db +PATH_LOGS=${PATH_BASE}/logs + +/usr/bin/goaccess "${PATH_LOGS}/nginx-access.log.1" \ + --agent-list --anonymize-ip --real-os \ + --output "${PATH_STATS}/index.html" --log-format COMBINED \ + --tz="${TZ}" "--db-path=${PATH_STATSDB}" --persist --restore