From d3322da5a58234fce19e4029a422bb138427c4bd Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Fri, 10 Jul 2026 11:57:21 +0200 Subject: [PATCH] Fix BirdNET-Pi standalone Caddy startup --- .../rootfs/custom-services.d/02-caddy.sh | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/birdnet-pi/rootfs/custom-services.d/02-caddy.sh b/birdnet-pi/rootfs/custom-services.d/02-caddy.sh index a5d18e8678..e009a13efd 100755 --- a/birdnet-pi/rootfs/custom-services.d/02-caddy.sh +++ b/birdnet-pi/rootfs/custom-services.d/02-caddy.sh @@ -1,25 +1,29 @@ #!/usr/bin/with-contenv bashio # shellcheck shell=bash -# Dependencies -sockfile="empty" -until [[ -e /var/run/dbus/system_bus_socket ]] && [[ -e "$sockfile" ]]; do +# Wait for PHP-FPM only. D-Bus is optional in standalone Docker mode and must +# not prevent the web service from starting. +sockfile="" +until [[ -n "$sockfile" ]] && [[ -e "$sockfile" ]]; do sleep 1s - sockfile="$(find /run/php -name "*.sock")" + sockfile="$(find /run/php -name "*.sock" -print -quit 2> /dev/null || true)" done # Correct fpm.sock -chown caddy:caddy /run/php/php*-fpm.sock +chown caddy:caddy "$sockfile" sed -i "s|/run/php/php-fpm.sock|$sockfile|g" /helpers/caddy_ingress.sh sed -i "s|/run/php/php-fpm.sock|$sockfile|g" /etc/caddy/Caddyfile sed -i "s|/run/php/php-fpm.sock|$sockfile|g" "$HOME"/BirdNET-Pi/scripts/update_caddyfile.sh -# Set timezone -TZ_VALUE="$(timedatectl show -p Timezone --value)" -export TZ="$TZ_VALUE" +# Set timezone without requiring D-Bus. +TZ_VALUE="${TZ:-}" +if [[ -S /var/run/dbus/system_bus_socket ]] && command -v timedatectl > /dev/null 2>&1; then + TZ_VALUE="$(timedatectl show -p Timezone --value 2> /dev/null || true)" +fi +export TZ="${TZ_VALUE:-Etc/UTC}" # Update caddyfile with password -/."$HOME"/BirdNET-Pi/scripts/update_caddyfile.sh &> /dev/null || true +"$HOME"/BirdNET-Pi/scripts/update_caddyfile.sh &> /dev/null || true echo "Starting service: caddy" -/usr/bin/caddy run --config /etc/caddy/Caddyfile +exec /usr/bin/caddy run --config /etc/caddy/Caddyfile