Files
hassio-addons/birdnet-pi/rootfs/custom-services.d/00-php_pfm.sh
alexbelgium c53263a29d Fix BirdNET-Pi standalone mode: strip sudo at build time + ensure /run/php
The build-time hook that removes `sudo` from the BirdNET-Pi scripts was
injected at line 2 of newinstaller.sh, i.e. before the repo is cloned, so it
was a no-op and `sudo` remained in 25 scripts. Outside Home Assistant this
breaks every script invoked by a non-sudoers user (php-fpm's `caddy` user for
the WebUI System Controls, or `abc`) with "X is not in the sudoers file",
which is what prevented standalone (no-Supervisor) operation. Move the strip
to run after the installer clones the repo. Also drop the unused (and, in this
fork, incorrect) `$my_dir` -> `/config` rewrite.

Additionally create /run/php before starting PHP-FPM: it is normally created
by systemd-tmpfiles, which does not run in this container, so on a fresh/tmpfs
/run the socket cannot be bound and the WebUI never comes up.

Verified against the published 2026.07.10 image: the WebUI serves HTTP 200 and
restart_services.sh runs cleanly as the non-sudoers `caddy` user.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-10 16:08:41 +02:00

24 lines
881 B
Bash
Executable File

#!/usr/bin/with-contenv bash
# shellcheck shell=bash
# Correct /config permissions after startup
chown pi:pi /config
# Ensure the PHP-FPM runtime directory exists. It is normally created by
# systemd-tmpfiles (/usr/lib/tmpfiles.d/php*-fpm.conf), which does not run in
# this container - so on a fresh/tmpfs /run the socket cannot be bound and the
# WebUI never starts. Create it here so the web stack works with or without
# Home Assistant Supervisor.
mkdir -p /run/php
chown www-data:www-data /run/php 2> /dev/null || true
# Set timezone without requiring Home Assistant Supervisor or 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}"
echo "Starting service: php pfm"
exec /usr/sbin/php-fpm* -F