From 717c8258f3cfccc7496a685291653c74ea912950 Mon Sep 17 00:00:00 2001 From: Alex Phillips Date: Thu, 3 Feb 2022 09:12:39 -0500 Subject: [PATCH] make access.log file configurable via ENV variable --- root/dashboard/goaccess.conf | 2 +- root/dashboard/www/index.php | 1 + root/etc/cont-init.d/98-dashboard-config | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/root/dashboard/goaccess.conf b/root/dashboard/goaccess.conf index 268a554..5861081 100644 --- a/root/dashboard/goaccess.conf +++ b/root/dashboard/goaccess.conf @@ -332,7 +332,7 @@ with-mouse false # Specify the path to the input log file. If set, it will take # priority over -f from the command line. # -log-file /config/log/nginx/access.log +#log-file /config/log/nginx/access.log # Send all debug messages to the specified file. # diff --git a/root/dashboard/www/index.php b/root/dashboard/www/index.php index 4be246f..7a5ff22 100644 --- a/root/dashboard/www/index.php +++ b/root/dashboard/www/index.php @@ -252,6 +252,7 @@ $geodb = ''; endif; + $access_log = getenv("GOACCESS_LOG_FILE") ?: "/config/log/nginx/access.log"; $goaccess = shell_exec("/usr/local/bin/goaccess -a -o html --config-file=/dashboard/goaccess.conf ".$geodb); $goaccess = str_replace("Server Statistics", "<title>SWAG Dashboard", $goaccess); $goaccess = str_replace("<h1 class='h-dashboard'>", "<h1>", $goaccess); diff --git a/root/etc/cont-init.d/98-dashboard-config b/root/etc/cont-init.d/98-dashboard-config index ac11c0e..d238501 100644 --- a/root/etc/cont-init.d/98-dashboard-config +++ b/root/etc/cont-init.d/98-dashboard-config @@ -22,6 +22,10 @@ if [ "$(sed -nE 's|## Version ([0-9]{4}\/[0-9]{2}\/[0-9]{2}).*|\1|p' /dashboard/ echo "**** Compare the changes using the sample file: /config/nginx/proxy-confs/dashboard.subdomain.conf.sample" fi +# preserve environment variables in PHP +sed -E -i 's/^clear_env =.*$/clear_env = no/g' /config/php/www2.conf +grep -qxF 'clear_env = no' /config/php/www2.conf || echo 'clear_env = no' >> /config/php/www2.conf + # permissions chown -R abc:abc \ /dashboard \