PHP shims: derive paths from __DIR__ (PHP-FPM runs as caddy user)
BirdNET-Pi's installer runs PHP-FPM as the caddy user, so getenv('HOME')
resolves to /var/lib/caddy - not the install user's home. Every path
constructed from getenv('HOME') was broken on first install.
PHP resolves __DIR__ through the install_services.sh symlink to the
realpath ($HOME/BirdNET-Pi/avian/api), so dirname(__DIR__, 2) = the
BirdNET-Pi install root and dirname(__DIR__, 3) = the user's home.
Works under any username because nothing is hardcoded.
Also fixed birdnet-api.php's DB_PATH which walked one level too far
(used , 3) - the BirdNET-Pi root is , 2).
This commit is contained in:
@@ -54,7 +54,7 @@ if (is_file($cutout) && filesize($cutout) > 1024) {
|
||||
}
|
||||
|
||||
// 3. Dynamic cache from a previous Wikipedia + rembg run.
|
||||
$cacheDir = getenv('HOME') . '/BirdSongs/Extracted/cutouts';
|
||||
$cacheDir = dirname(__DIR__, 3) . '/BirdSongs/Extracted/cutouts';
|
||||
$cachePath = "$cacheDir/$slug.png";
|
||||
if (is_file($cachePath) && filesize($cachePath) > 1024) {
|
||||
serve_png($cachePath);
|
||||
|
||||
Reference in New Issue
Block a user