mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-08-01 10:50:32 +02:00
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>
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
## 2026.07.10-1 (10-07-2026)
|
||||
- Fix standalone (no-Supervisor) mode: strip `sudo` from BirdNET-Pi scripts at build time (the previous hook ran before the repo was cloned, so `sudo` remained and broke service/WebUI actions run by non-sudoers users such as `caddy`/`abc`)
|
||||
- Ensure `/run/php` exists before starting PHP-FPM so the WebUI starts even when `/run` is a fresh tmpfs
|
||||
## 2026.07.10 (10-07-2026)
|
||||
- Minor bugs fixed
|
||||
## 2026.06.01 (19-06-2026)
|
||||
|
||||
@@ -74,17 +74,6 @@ RUN \
|
||||
curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/BirdNET-Pi/main/newinstaller.sh" -o /newinstaller.sh && \
|
||||
chmod 777 /newinstaller.sh && \
|
||||
\
|
||||
# Use installer to modify other scripts
|
||||
#######################################
|
||||
# Define file
|
||||
sed -i "1a /./newinstallermod.sh" /newinstaller.sh && \
|
||||
echo '#!/bin/bash' >> /newinstallermod.sh && \
|
||||
# Remove all instances of sudo from all other scripts
|
||||
echo 'for file in $(grep -srl "sudo" $HOME/BirdNET-Pi/scripts); do sed -i "s|sudo ||" "$file"; done' >> /newinstallermod.sh && \
|
||||
echo 'for file in $(grep -srl "my_dir" $HOME/BirdNET-Pi/scripts); do sed -i "s|\$my_dir|/config|" "$file"; done' >> /newinstallermod.sh && \
|
||||
# Set permission
|
||||
chmod +x /newinstallermod.sh && \
|
||||
\
|
||||
# Modify installer
|
||||
##################
|
||||
# Use my repository
|
||||
@@ -110,6 +99,16 @@ RUN \
|
||||
# Execute installer
|
||||
/./newinstaller.sh && \
|
||||
\
|
||||
# Remove sudo from the installed BirdNET-Pi scripts.
|
||||
# Inside the container everything already runs with the privileges it needs
|
||||
# (root during init, user "pi" for the services), so "sudo" is never required.
|
||||
# Leaving it in breaks any script invoked by a user that is not in sudoers -
|
||||
# e.g. php-fpm's "caddy" user driving the WebUI System Controls, or the "abc"
|
||||
# user - which is what prevented BirdNET-Pi from working in standalone
|
||||
# (no-Supervisor) mode. This must run AFTER the installer has cloned the repo;
|
||||
# the previous build-time hook ran before the clone and was therefore a no-op.
|
||||
for file in $(grep -srlF "sudo " "$HOME/BirdNET-Pi/scripts"); do sed -i "s|sudo ||g" "$file"; done && \
|
||||
\
|
||||
# Install dateparser and resampy, upgrade numpy
|
||||
$PYTHON_VIRTUAL_ENV /usr/bin/pip3 install dateparser resampy && \
|
||||
\
|
||||
|
||||
@@ -116,5 +116,5 @@ tmpfs: true
|
||||
udev: true
|
||||
url: https://github.com/alexbelgium/hassio-addons/tree/master/birdnet-pi
|
||||
usb: true
|
||||
version: 2026.07.10
|
||||
version: 2026.07.10-1
|
||||
video: true
|
||||
|
||||
@@ -4,6 +4,14 @@
|
||||
# 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
|
||||
|
||||
Reference in New Issue
Block a user