Adjusting systemd unit files to avoid hardcoded UID in the runtime dir path (#461)

* Update install_services.sh

Replaced hardcoded uid

* Update install_services.sh

avoid uid in /run path

* Update install_services.sh

had to use $(id)

* Update update_birdnet_snippets.sh

Remove XDG_RUNTIME_DIR from templates

* removed XDG_RUNTIME_DIR

* update HIDE_MOUNTS runtime paths

uid agnostic

* typos
This commit is contained in:
cjwaian
2025-09-23 09:17:22 -07:00
committed by GitHub
parent af5c8ddf9d
commit 29eb69025a
2 changed files with 22 additions and 6 deletions
-3
View File
@@ -119,7 +119,6 @@ install_recording_service() {
[Unit] [Unit]
Description=BirdNET Recording Description=BirdNET Recording
[Service] [Service]
Environment=XDG_RUNTIME_DIR=/run/user/1000
Restart=always Restart=always
Type=simple Type=simple
RestartSec=3 RestartSec=3
@@ -138,7 +137,6 @@ install_custom_recording_service() {
[Unit] [Unit]
Description=BirdNET Custom Recording Description=BirdNET Custom Recording
[Service] [Service]
Environment=XDG_RUNTIME_DIR=/run/user/1000
Restart=always Restart=always
Type=simple Type=simple
RestartSec=3 RestartSec=3
@@ -365,7 +363,6 @@ Description=BirdNET-Pi Live Stream
After=network-online.target After=network-online.target
Requires=network-online.target Requires=network-online.target
[Service] [Service]
Environment=XDG_RUNTIME_DIR=/run/user/1000
Restart=always Restart=always
Type=simple Type=simple
RestartSec=3 RestartSec=3
+19
View File
@@ -197,10 +197,29 @@ if grep -q -e '-P terminal' $HOME/BirdNET-Pi/templates/web_terminal.service ;the
systemctl daemon-reload && restart_services.sh systemctl daemon-reload && restart_services.sh
fi fi
if grep -q -e 'Environment=XDG_RUNTIME_DIR=/run/user/' $HOME/BirdNET-Pi/templates/birdnet_recording.service; then
sed -i '/^Environment=XDG_RUNTIME_DIR=\/run\/user\/[0-9]\+/d' $HOME/BirdNET-Pi/templates/birdnet_recording.service
systemctl daemon-reload && restart_services.sh
fi
if grep -q -e 'Environment=XDG_RUNTIME_DIR=/run/user/' $HOME/BirdNET-Pi/templates/custom_recording.service; then
sed -i '/^Environment=XDG_RUNTIME_DIR=\/run\/user\/[0-9]\+/d' $HOME/BirdNET-Pi/templates/custom_recording.service
systemctl daemon-reload && restart_services.sh
fi
if grep -q -e 'Environment=XDG_RUNTIME_DIR=/run/user/' $HOME/BirdNET-Pi/templates/livestream.service; then
sed -i '/^Environment=XDG_RUNTIME_DIR=\/run\/user\/[0-9]\+/d' $HOME/BirdNET-Pi/templates/livestream.service
systemctl daemon-reload && restart_services.sh
fi
if grep -q 'php7.4-' /etc/caddy/Caddyfile &>/dev/null; then if grep -q 'php7.4-' /etc/caddy/Caddyfile &>/dev/null; then
sed -i 's/php7.4-/php-/' /etc/caddy/Caddyfile sed -i 's/php7.4-/php-/' /etc/caddy/Caddyfile
fi fi
if grep -q '^HIDE_MOUNTS.*\/run\/user' $HOME/BirdNET-Pi/templates/phpsysinfo.ini; then
sed -i 's#/run/user/[0-9]\+#/run/user/[0-9]+#g' $HOME/BirdNET-Pi/templates/phpsysinfo.ini
fi
if ! [ -L /etc/avahi/services/http.service ];then if ! [ -L /etc/avahi/services/http.service ];then
# symbolic link does not work here, so just copy # symbolic link does not work here, so just copy
cp -f $HOME/BirdNET-Pi/templates/http.service /etc/avahi/services/ cp -f $HOME/BirdNET-Pi/templates/http.service /etc/avahi/services/