From 2b979cec246353c2ea82e35fd1fc3c94e29e9fe6 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 16 May 2024 21:15:10 +0200 Subject: [PATCH] Create 72-newfeatures.sh --- .../rootfs/etc/cont-init.d/72-newfeatures.sh | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 birdnet-pi/rootfs/etc/cont-init.d/72-newfeatures.sh diff --git a/birdnet-pi/rootfs/etc/cont-init.d/72-newfeatures.sh b/birdnet-pi/rootfs/etc/cont-init.d/72-newfeatures.sh new file mode 100644 index 000000000..0e6581090 --- /dev/null +++ b/birdnet-pi/rootfs/etc/cont-init.d/72-newfeatures.sh @@ -0,0 +1,67 @@ +#!/command/with-contenv bashio +# shellcheck shell=bash +set -e + +################ +# ADD FEATURES # +################ + +echo " " +bashio::log.info "Adding new features" + +# Set the online birds info system +if [[ "$(bashio::config "BIRDS_ONLINE_INFO")" == *"ebird"* ]]; then + echo "... using ebird instead of allaboutbirds" + # Set ebird database + mv /helpers/ebird.txt /home/pi/BirdNET-Pi/model/ebird.txt + chown pi:pi /home/pi/BirdNET-Pi/model/ebird.txt + # Get language + export "$(grep "^DATABASE_LANG" /config/birdnet.conf)" + # shellcheck disable=SC2016 + sed -i '/$sciname =/a \\t$ebirdname = shell_exec("grep \\"$( echo \\"$sciname\\" | sed '\''s/_/ /g'\'')\\" /home/pi/BirdNET-Pi/model/ebird.txt | cut -d'\''_'\'' -f2 | sed '\''s/ /_/g'\''");' "$HOME"/BirdNET-Pi/scripts/todays_detections.php + sed -i "s|https://allaboutbirds.org/guide/|https://ebird.org/species/?siteLanguage=${DATABASE_LANG}_${DATABASE_LANG}|g" "$HOME"/BirdNET-Pi/scripts/todays_detections.php + # shellcheck disable=SC2016 + sed -i '/$sciname =/a \\t$ebirdname = shell_exec("grep \\"$( echo \\"$sciname\\" | sed '\''s/_/ /g'\'')\\" /home/pi/BirdNET-Pi/model/ebird.txt | cut -d'\''_'\'' -f2 | sed '\''s/ /_/g'\''");' "$HOME"/BirdNET-Pi/scripts/stats.php + sed -i "s|https://allaboutbirds.org/guide/\$comname|https://ebird.org/species/\$ebirdname?siteLanguage=${DATABASE_LANG}_${DATABASE_LANG}|g" "$HOME"/BirdNET-Pi/scripts/stats.php +else + # Correct allaboutbirds for non-english names + echo "... using allaboutbirds, with correction for non-english names" + # shellcheck disable=SC2016 + sed -i 's|allaboutbirds.org/guide/