Skip to content

A live bird collage card for your Home Assistant dashboard.

update snippets for birdnet_analysis.py

frederik87e694ec14ba
diff --git a/scripts/install_services.sh b/scripts/install_services.sh
index bd9244a4..454f9e86 100755
--- a/scripts/install_services.sh
+++ b/scripts/install_services.sh
@@ -20,7 +20,7 @@ install_depends() {
apt install -qqy caddy ftpd sqlite3 php-sqlite3 alsa-utils \
pulseaudio avahi-utils sox libsox-fmt-mp3 php php-fpm php-curl php-xml \
php-zip icecast2 swig ffmpeg wget unzip curl cmake make bc libjpeg-dev \
- zlib1g-dev python3-dev python3-pip python3-venv lsof net-tools
+ zlib1g-dev python3-dev python3-pip python3-venv lsof net-tools gcc python3-dev
}
@@ -43,15 +43,12 @@ install_birdnet_analysis() {
cat << EOF > $HOME/BirdNET-Pi/templates/birdnet_analysis.service
[Unit]
Description=BirdNET Analysis
-After=birdnet_server.service
-Requires=birdnet_server.service
[Service]
-RuntimeMaxSec=900
Restart=always
Type=simple
RestartSec=2
User=${USER}
-ExecStart=/usr/local/bin/birdnet_analysis.sh
+ExecStart=$PYTHON_VIRTUAL_ENV /usr/local/bin/birdnet_analysis.py
[Install]
WantedBy=multi-user.target
EOF
diff --git a/scripts/update_birdnet_snippets.sh b/scripts/update_birdnet_snippets.sh
index 5088f3dc..cc7a4072 100755
--- a/scripts/update_birdnet_snippets.sh
+++ b/scripts/update_birdnet_snippets.sh
@@ -55,10 +55,30 @@ ensure_python_package() {
}
# update snippets below
+if ! which inotifywait &>/dev/null;then
+ ensure_apt_updated
+ apt-get -y install inotify-tools
+fi
+if ! which gcc &>/dev/null;then
+ ensure_apt_updated
+ apt-get -y install gcc python3-dev
+fi
+
+ensure_python_package inotify inotify
+
if ! grep 'daemon' $HOME/BirdNET-Pi/templates/chart_viewer.service &>/dev/null;then
sed -i "s|daily_plot.py.*|daily_plot.py --daemon --sleep 2|" ~/BirdNET-Pi/templates/chart_viewer.service
systemctl daemon-reload && restart_services.sh
fi
+
+if grep -q 'birdnet_server.service' "$HOME/BirdNET-Pi/templates/birdnet_analysis.service"&>/dev/null; then
+ sed -i '/After=.*/d' "$HOME/BirdNET-Pi/templates/birdnet_analysis.service"
+ sed -i '/Requires=.*/d' "$HOME/BirdNET-Pi/templates/birdnet_analysis.service"
+ sed -i '/RuntimeMaxSec=.*/d' "$HOME/BirdNET-Pi/templates/birdnet_analysis.service"
+ sed -i "s|ExecStart=.*|ExecStart=$HOME/BirdNET-Pi/birdnet/bin/python3 /usr/local/bin/birdnet_analysis.py|" "$HOME/BirdNET-Pi/templates/birdnet_analysis.service"
+ systemctl daemon-reload && restart_services.sh
+fi
+
# update snippets above
systemctl daemon-reload