diff --git a/Containers/mastercontainer/acme.Caddyfile b/Containers/mastercontainer/acme.Caddyfile index 77d7df9e..fc3e37de 100644 --- a/Containers/mastercontainer/acme.Caddyfile +++ b/Containers/mastercontainer/acme.Caddyfile @@ -10,7 +10,7 @@ } log { - level ERROR + level {$CADDY_LOG_LEVEL} # We need to exclude the remote-host plugin from logging as it would spam the logs # See https://github.com/nextcloud/all-in-one/pull/7006#issuecomment-4003238239 exclude http.matchers.remote_host diff --git a/Containers/mastercontainer/backup-time-file-watcher.sh b/Containers/mastercontainer/backup-time-file-watcher.sh index ec9154ab..6c5fc80d 100644 --- a/Containers/mastercontainer/backup-time-file-watcher.sh +++ b/Containers/mastercontainer/backup-time-file-watcher.sh @@ -1,5 +1,9 @@ #!/bin/bash +if [ "$AIO_LOG_LEVEL" = 'debug' ]; then + set -x +fi + restart_process() { echo "Restarting cron.sh because daily backup time was set, changed or unset." pkill cron.sh diff --git a/Containers/mastercontainer/cron.sh b/Containers/mastercontainer/cron.sh index 40a9b4ba..af0a25bc 100644 --- a/Containers/mastercontainer/cron.sh +++ b/Containers/mastercontainer/cron.sh @@ -1,5 +1,9 @@ #!/bin/bash +if [ "$AIO_LOG_LEVEL" = 'debug' ]; then + set -x +fi + while true; do if [ -f "/mnt/docker-aio-config/data/daily_backup_time" ]; then set -x @@ -17,7 +21,9 @@ while true; do else export SEND_SUCCESS_NOTIFICATIONS=0 fi - set +x + if [ "$AIO_LOG_LEVEL" != 'debug' ]; then + set +x + fi if [ -f "/mnt/docker-aio-config/data/daily_backup_running" ]; then export LOCK_FILE_PRESENT=1 else diff --git a/Containers/mastercontainer/daily-backup.sh b/Containers/mastercontainer/daily-backup.sh index 89ef3cd5..99293b60 100644 --- a/Containers/mastercontainer/daily-backup.sh +++ b/Containers/mastercontainer/daily-backup.sh @@ -1,5 +1,9 @@ #!/bin/bash +if [ "$AIO_LOG_LEVEL" = 'debug' ]; then + set -x +fi + echo "Daily backup script has started" # Check if initial configuration has been done, otherwise this script should do nothing. diff --git a/Containers/mastercontainer/healthcheck.sh b/Containers/mastercontainer/healthcheck.sh index 3f773553..db77524b 100644 --- a/Containers/mastercontainer/healthcheck.sh +++ b/Containers/mastercontainer/healthcheck.sh @@ -1,5 +1,9 @@ #!/bin/bash +if [ "$AIO_LOG_LEVEL" = 'debug' ]; then + set -x +fi + if [ -f "/mnt/docker-aio-config/data/configuration.json" ]; then nc -z 127.0.0.1 80 || exit 1 nc -z 127.0.0.1 8080 || exit 1 diff --git a/Containers/mastercontainer/internal.Caddyfile b/Containers/mastercontainer/internal.Caddyfile index 9890acc0..f9c1a648 100644 --- a/Containers/mastercontainer/internal.Caddyfile +++ b/Containers/mastercontainer/internal.Caddyfile @@ -9,7 +9,7 @@ } log { - level ERROR + level {$CADDY_LOG_LEVEL} # We need to exclude the remote-host plugin from logging as it would spam the logs # See https://github.com/nextcloud/all-in-one/pull/7006#issuecomment-4003238239 exclude http.matchers.remote_host diff --git a/Containers/mastercontainer/session-deduplicator.sh b/Containers/mastercontainer/session-deduplicator.sh index 08ec0f9c..73f886ba 100644 --- a/Containers/mastercontainer/session-deduplicator.sh +++ b/Containers/mastercontainer/session-deduplicator.sh @@ -16,6 +16,10 @@ compare_times() { fi } +if [ "$AIO_LOG_LEVEL" = 'debug' ]; then + set -x +fi + while true; do compare_times sleep 2 diff --git a/Containers/mastercontainer/start.sh b/Containers/mastercontainer/start.sh index 8acce175..7a808548 100644 --- a/Containers/mastercontainer/start.sh +++ b/Containers/mastercontainer/start.sh @@ -20,6 +20,10 @@ case "${1}" in esac } +if [ "$AIO_LOG_LEVEL" = 'debug' ]; then + set -x +fi + # Check if running as root user if [ "$EUID" != "0" ]; then print_red "Container does not run as root user. This is not supported." @@ -333,6 +337,24 @@ else export NEXTCLOUD_DRI_GID="" fi +# Log level logics +if [ -n "$AIO_LOG_LEVEL" ] && ! grep -q "^debug$\|^info$\|^warn$\|^error$"; then + print_red "AIO_LOG_LEVEL must be one of 'debug', 'info', 'warn' or 'error'. +It is set to '$AIO_LOG_LEVEL'". + exit 1 +fi +if [ -z "$AIO_LOG_LEVEL" ]; then + export AIO_LOG_LEVEL="warn" +fi + +CADDY_LOG_LEVEL="$(echo "$AIO_LOG_LEVEL" | tr '[:lower:]' '[:upper:]')" +if [ "$AIO_LOG_LEVEL" = 'debug' ]; then + export SUPERVISORD_STDOUT=/dev/stdout +else + export SUPERVISORD_STDOUT=NONE +fi +export CADDY_LOG_LEVEL + # Check if ghcr.io is reachable # Solves issues like https://github.com/nextcloud/all-in-one/discussions/5268 if ! curl --no-progress-meter https://ghcr.io/v2/ >/dev/null; then diff --git a/Containers/mastercontainer/supervisord.conf b/Containers/mastercontainer/supervisord.conf index 9fbb9516..df682fff 100644 --- a/Containers/mastercontainer/supervisord.conf +++ b/Containers/mastercontainer/supervisord.conf @@ -5,12 +5,12 @@ pidfile=/var/run/supervisord/supervisord.pid childlogdir=/var/log/supervisord/ logfile_maxbytes=50MB logfile_backups=10 -loglevel=error +loglevel=%(ENV_AIO_LOG_LEVEL)s user=root [program:php-fpm] # Stdout logging is disabled as otherwise the logs are spammed -stdout_logfile=NONE +stdout_logfile=%(ENV_SUPERVISORD_STDOUT)s stderr_logfile=/dev/stderr stderr_logfile_maxbytes=0 command=php-fpm @@ -58,7 +58,7 @@ user=root [program:domain-validator] # Logging is disabled as otherwise all attempts will be logged which spams the logs -stdout_logfile=NONE -stderr_logfile=NONE +stdout_logfile=%(ENV_SUPERVISORD_STDOUT)s +stderr_logfile=%(ENV_SUPERVISORD_STDOUT)s command=php -S 127.0.0.1:9876 /var/www/docker-aio/php/domain-validator.php user=www-data