A live bird collage card for your Home Assistant dashboard.
adjustments to the installer and updater to ensure `lsof` is installed
mcguirepr89eb8fdd2d8a9c
diff --git a/scripts/install_services.sh b/scripts/install_services.shindex 7b486ae2..b19e3997 100755--- a/scripts/install_services.sh+++ b/scripts/install_services.sh@@ -18,7 +18,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+ zlib1g-dev python3-dev python3-pip python3-venv lsof}diff --git a/scripts/most_recent.sh b/scripts/most_recent.shnew file mode 100755index 00000000..cf102496--- /dev/null+++ b/scripts/most_recent.sh@@ -0,0 +1,31 @@+#!/usr/bin/env bash+OLDIFS=$IFS+IFS=\|+most_recent_results=($(sqlite3 ~/BirdNET-Pi/scripts/birds.db \+ 'SELECT Com_Name, Time, Date FROM detections+ ORDER BY Date DESC, Time DESC+ LIMIT 1'))+today=$(date +%F)+yesterday=$(date --date="yesterday" +%F)+two_days_ago=$(date --date="2 days ago" +%F)++echo -n The most recent detection was++if [[ "${most_recent_results[0]}" =~ ^[AEIOU].* ]];then+ echo -n " an ${most_recent_results[0]} at "+else+ echo -n " a ${most_recent_results[0]} at "+fi+most_recent_results[1]=$(date --date="${most_recent_results[1]}" +%l:%M%p)+echo -n ${most_recent_results[1]}+if [[ ${most_recent_results[2]} == $today ]];then+ echo " today."+elif [[ ${most_recent_results[2]} == $yesterday ]];then+ echo " yesterday."+elif [[ ${most_recent_results[2]} == $two_days_ago ]];then+ echo " two days ago."+else+ echo " on ${most_recent_results[2]}."+fi++IFS=$OLDIFSdiff --git a/scripts/update_birdnet.sh b/scripts/update_birdnet.shindex a48e7d62..254efd15 100755--- a/scripts/update_birdnet.sh+++ b/scripts/update_birdnet.sh@@ -11,10 +11,4 @@ sudo -u${USER} git -C $my_dir pull -fsudo systemctl daemon-reloadsudo -u${USER} git -C $my_dir stash popsudo ln -sf $my_dir/* /usr/local/bin/-if ! grep python3 <(head -n1 $my_dir/analyze.py);then- echo "Ensure all python scripts use the virtual environment"- sed -si "1 i\\#\!$HOME/BirdNET-Pi/birdnet/bin/python3" $my_dir/*.py-fi-if ! grep PRIVACY_MODE /etc/birdnet/birdnet.conf;then- sudo -u${USER} echo "PRIVACY_MODE=off" >> /etc/birdnet/birdnet.conf-fi+sudo $my_dir/update_birdnet_snippets.shdiff --git a/scripts/update_birdnet_snippets.sh b/scripts/update_birdnet_snippets.shnew file mode 100755index 00000000..5e63ff71--- /dev/null+++ b/scripts/update_birdnet_snippets.sh@@ -0,0 +1,17 @@+#!/usr/bin/env bash+# Update BirdNET-Pi+source /etc/birdnet/birdnet.conf+trap 'exit 1' SIGINT SIGHUP+USER=$(awk -F: '/1000/ {print $1}' /etc/passwd)+HOME=$(awk -F: '/1000/ {print $6}' /etc/passwd)+my_dir=$HOME/BirdNET-Pi/scripts+if ! grep python3 <(head -n1 $my_dir/analyze.py);then+ echo "Ensure all python scripts use the virtual environment"+ sed -si "1 i\\#\!$HOME/BirdNET-Pi/birdnet/bin/python3" $my_dir/*.py+fi+if ! grep PRIVACY_MODE /etc/birdnet/birdnet.conf;then+ sudo -u${USER} echo "PRIVACY_MODE=off" >> /etc/birdnet/birdnet.conf+fi+if ! which lsof &>/dev/null;then+ sudo apt update && sudo apt -y install lsof+fi