diff --git a/.gitignore b/.gitignore index d956f22..e381fac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ *.pyc *.flac -model/BirdNET_Soundscape_Model.pkl +model/* .vscode datasets/ birdnet.conf diff --git a/Birders_Guide_Installer.sh b/Birders_Guide_Installer.sh index 55c88ac..01b4d68 100755 --- a/Birders_Guide_Installer.sh +++ b/Birders_Guide_Installer.sh @@ -71,10 +71,7 @@ and then close the Mouse Pad editing window to continue." echo "Installing the BirdNET-Pi configuration file." install_birdnet_config || exit 1 echo "Installing BirdNET-Lite" - if ${my_dir}/scripts/install_birdnet.sh << EOF ; then - -n -EOF + if ${my_dir}/scripts/install_birdnet.sh;then echo "The next time you power on the raspberry pi, all of the services will start up automatically. The installation has finished. Press Enter to close this window." diff --git a/README.md b/README.md index 5bc64f2..03ec43c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@

- BirdNET-Pi + BirdNET-Pi

A realtime acoustic bird classification system for the Raspberry Pi 4B diff --git a/birdnet.conf-defaults b/birdnet.conf-defaults index bc292c3..57a2c99 100644 --- a/birdnet.conf-defaults +++ b/birdnet.conf-defaults @@ -33,14 +33,14 @@ RECS_DIR=/home/pi/BirdSongs ## CADDY_PWD is the plaintext password (that will be hashed) and used to access ## certain parts of the web interface -CADDY_PWD=changeme +CADDY_PWD= #------------------------- MariaDB User Passwords ---------------------------# #_____________The variable below sets the password for the_____________________# #_______________________'birder' user on the MariaDB___________________________# ## DB_PWD is for the 'birder' user -DB_PWD=changeme +DB_PWD=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;) #------------------------- Live Audio Stream --------------------------------# #_____________The variable below configures/enables the live___________________# @@ -51,7 +51,7 @@ DB_PWD=changeme ## trusted source for the stream. You will never need to enter this manually ## anywhere other than here. -ICE_PWD=changeme +ICE_PWD=birdnetpi #--------------------- BirdWeather Station Information -----------------------# #_____________The variable below can be set to have your BirdNET-Pi____________# diff --git a/homepage/form.html b/homepage/form.html new file mode 100644 index 0000000..2b3d2a6 --- /dev/null +++ b/homepage/form.html @@ -0,0 +1,84 @@ + + + Configure `birdnet.conf` + + +

Configure BirdNET-Pi

+ +
+

Required

+ +
+ +
+ +
+ +
+ +
+ +
+
+

Optional Services

+ +
+ +
+ +
+ +
+
+

Custom URLs

+ +
+ +
+ +
+ +
+
+

Default Services

+ +
+ +
+ +
+ +
+
+

Advanced Configuration

+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ View Current Config + + diff --git a/homepage/form.php b/homepage/form.php new file mode 100644 index 0000000..534b525 --- /dev/null +++ b/homepage/form.php @@ -0,0 +1,24 @@ +"; +echo "File:
"; +$file = file("scripts/birdnet.conf"); +foreach($file as $text) { +echo $text."
"; +} +}else{ +$file = file("scripts/birdnet.conf"); +echo "
"; +echo ""; +echo "\n +
"; +} +?> diff --git a/homepage/images/version.svg b/homepage/images/version.svg index 19d4262..2f0d67a 100644 --- a/homepage/images/version.svg +++ b/homepage/images/version.svg @@ -1 +1 @@ -version: 0.10version0.10 +version: 0.11version0.11 diff --git a/homepage/menu_de.html b/homepage/menu_de.html new file mode 100644 index 0000000..39c5652 --- /dev/null +++ b/homepage/menu_de.html @@ -0,0 +1,80 @@ + + + Menu + + + + +
Extraktionen
+ - Nach Datum
+ - Nach Namen
+ - Nach wiss. Namen
+ - Verarbeitet
+ +
+ +
System-Links
+ - Tools
+ - System Info
+ - BirdNET-Lite Log
+ - Extraction Log
+ +
+ +
Externe Links
+ - BirdWeather
+ - Repository
+ - Wiki Hilfe-Seite
+ - Wttr.in Report
+ - BirdNET @ Cornell
+
+ +
Andere
BirdNET-Pis
+ - United States
+ - South Africa
+ - Sweden + - Germany + + + + + diff --git a/homepage/top.html b/homepage/top.html index 8308b52..a038a46 100644 --- a/homepage/top.html +++ b/homepage/top.html @@ -14,33 +14,33 @@ body { margin:10px; background-color: rgb(119, 196, 135); } - #content { - position: relative; - } - #content img { - position: absolute; - top: 0px; - left: 0px; - padding-top: 5px; - padding-left: 10px; - } - footer { - position: absolute; - bottom: 0px; - left: 0px; - right: 0px; - width: 100%; +#content { + position: relative; +} +#content img { + position: absolute; + top: 0px; + left: 0px; + padding-top: 5px; + padding-left: 10px; +} +footer { + position: absolute; + bottom: 0px; + left: 0px; + right: 0px; + width: 100%; - } +} BirdNET-Pi -

BirdNET-Pi

- -

+

BirdNET-Pi

+ +

Overview | Database View | Today View | diff --git a/homepage/top_de.html b/homepage/top_de.html new file mode 100644 index 0000000..30db041 --- /dev/null +++ b/homepage/top_de.html @@ -0,0 +1,51 @@ + + + + BirdNET-Pi + + + + + BirdNET-Pi + +

BirdNET-Pi

+ +

+ Übersicht | + Datenbankansicht | + Tagesansicht | + Spektrogrammansicht +

+ + diff --git a/homepage/write_config.php b/homepage/write_config.php new file mode 100755 index 0000000..398dda7 --- /dev/null +++ b/homepage/write_config.php @@ -0,0 +1,295 @@ + /dev/null;then + sudo apt update sudo apt -y install git fi git clone -b ${branch} https://github.com/mcguirepr89/BirdNET-Pi.git ${HOME}/BirdNET-Pi -${HOME}/BirdNET-Pi/scripts/birdnet-pi-config +cp ${HOME}/BirdNET-Pi/birdnet.conf-defaults ${HOME}/BirdNET-Pi/birdnet.conf +${HOME}/BirdNET-Pi/scripts/install_birdnet.sh diff --git a/requirements.txt b/requirements.txt index 8e747ea..ff000e5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,3 +5,4 @@ pytz tzlocal pandas seaborn +babel diff --git a/scripts/advanced.php b/scripts/advanced.php new file mode 100644 index 0000000..707f4b5 --- /dev/null +++ b/scripts/advanced.php @@ -0,0 +1,144 @@ + + + +

Advanced Settings

+ +
+
+
+ +

Defaults

+ +
+ +
+ +
+ +
+ +
+

Passwords

+ +
+ +
+ +
+
+
+

Custom URLs

+ +
+ +
+ +
+

BirdNET-Lite Settings

+ +
+ +
+ +
+
+
+ "> +
+
+
+ + +
+
+ + diff --git a/scripts/birdnet-pi-config b/scripts/birdnet-pi-config index 1007185..8eac2b6 100755 --- a/scripts/birdnet-pi-config +++ b/scripts/birdnet-pi-config @@ -221,7 +221,6 @@ do_wifi_country() { get_labels_lang() { oIFS="$IFS" - #value=$(unzip -l ${birdnetpi_dir}/model/labels_l18n.zip | awk '{print $4}' | tail -n +4 | grep -ve '^$' | tr '\n' '/') value=$(cat ${birdnetpi_dir}/model/labels_lang.txt | tr ',' ' ' | tr '\n' ' ') IFS=" " get_lang=$(whiptail --menu "Select the file that corresponds to your language" 20 60 10 ${value} 3>&1 1>&2 2>&3) diff --git a/scripts/config.php b/scripts/config.php new file mode 100644 index 0000000..6313897 --- /dev/null +++ b/scripts/config.php @@ -0,0 +1,151 @@ + + + +

Basic Settings

+ +
+
+
+ + +
+ +
+ +
+ +
+ +
+
+ + +

+ "> +
+
+ +
+
+
+ diff --git a/scripts/index.html b/scripts/index.html index 17e13d2..5652e8e 100644 --- a/scripts/index.html +++ b/scripts/index.html @@ -45,31 +45,31 @@ a { cursor: pointer; text-align: center; } -@media screen and (max-width: 800px) { - .column { - float: none; - width: 100%; + @media screen and (max-width: 800px) { + .column { + float: none; + width: 100%; + } } -}
- +
- +
- +
- +
- +
@@ -79,18 +79,18 @@ a {
- -
- + + +
- +
- +
- +
diff --git a/scripts/install_birdnet.sh b/scripts/install_birdnet.sh index f2d9825..e95ac05 100755 --- a/scripts/install_birdnet.sh +++ b/scripts/install_birdnet.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # Install BirdNET script -#set -x # debugging +set -x # debugging set -e # exit installation if anything fails my_dir=$(realpath $(dirname $0)) trap '${my_dir}/dump_logs.sh && echo -e "\n\nExiting the installation. Goodbye!" && exit 1' SIGINT @@ -20,8 +20,8 @@ fi sudo ./install_services.sh || exit 1 source /etc/birdnet/birdnet.conf -APT_DEPS=(swig ffmpeg wget unzip curl cmake make) -LIBS_MODULES=(libjpeg-dev zlib1g-dev python3-dev python3-pip) +APT_DEPS=(swig ffmpeg wget unzip curl cmake make bc) +LIBS_MODULES=(libjpeg-dev zlib1g-dev python3-dev python3-pip python3-venv) install_deps() { echo " Checking dependencies" @@ -70,15 +70,6 @@ install_birdnet() { pip3 install -U -r /home/pi/BirdNET-Pi/requirements.txt } -read -sp "\ -Be sure you have read the software license before installing. This is -available in the BirdNET-Pi directory as "LICENSE" -If you DO NOT want to install BirdNET and the birdnet_analysis.service, -press Ctrl+C to cancel. If you DO wish to install BirdNET and the -birdnet_analysis.service, press ENTER to continue with the installation." -echo -echo - [ -d ${RECS_DIR} ] || mkdir -p ${RECS_DIR} &> /dev/null install_deps diff --git a/scripts/install_config.sh b/scripts/install_config.sh index 26b407f..600eebb 100755 --- a/scripts/install_config.sh +++ b/scripts/install_config.sh @@ -5,6 +5,7 @@ set -e trap 'exit 1' SIGINT SIGHUP my_dir=$(realpath $(dirname $0)) +birdnetpi_dir=$(realpath $(dirname $my_dir)) BIRDNET_CONF="$(dirname ${my_dir})/birdnet.conf" get_RECS_DIR() { @@ -375,12 +376,19 @@ EOF # non-interactive installation. Otherwise,the installation is interactive. if [ -f ${BIRDNET_CONF} ];then source ${BIRDNET_CONF} + chmod g+w ${BIRDNET_CONF} + sed -i "s/LATITUDE=.*/LATITUDE=${LATITUDE}/g" ${BIRDNET_CONF} + sed -i "s/LONGITUDE=.*/LONGITUDE=${LONGITUDE}/g" ${BIRDNET_CONF} + sed -i "s/DB_PWD=.*/DB_PWD=${DB_PWD}/g" ${BIRDNET_CONF} #install_birdnet_conf [ -d /etc/birdnet ] || sudo mkdir /etc/birdnet sudo ln -sf $(dirname ${my_dir})/birdnet.conf /etc/birdnet/birdnet.conf + grep -ve '^#' -e '^$' /etc/birdnet/birdnet.conf > ${birdnetpi_dir}/firstrun.ini else configure install_birdnet_conf + chmod g+w ${BIRDNET_CONF} [ -d /etc/birdnet ] || sudo mkdir /etc/birdnet sudo ln -sf $(dirname ${my_dir})/birdnet.conf /etc/birdnet/birdnet.conf + grep -ve '^#' -e '^$' /etc/birdnet/birdnet.conf > ${birdnetpi_dir}/firstrun.ini fi diff --git a/scripts/install_services.sh b/scripts/install_services.sh index e9e4506..f1f311b 100755 --- a/scripts/install_services.sh +++ b/scripts/install_services.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # This installs the services that have been selected -#set -x # Uncomment to enable debugging +set -x # Uncomment to enable debugging trap 'rm -f ${tmpfile}' EXIT trap 'exit 1' SIGINT SIGHUP USER=pi @@ -16,10 +16,13 @@ set_hostname() { echo "Setting hostname to 'birdnetpi'" hostnamectl set-hostname birdnetpi sed -i 's/raspberrypi/birdnetpi/g' /etc/hosts - sed -i 's/localhost$/localhost birdnetpi.local/g' /etc/hosts fi } +update_system() { + apt update && apt -y upgrade +} + install_scripts() { echo "Installing BirdNET-Pi scripts to /usr/local/bin" ln -sf ${my_dir}/* /usr/local/bin/ @@ -188,6 +191,15 @@ install_alsa() { apt install -qqy pulseaudio echo "PulseAudio installed" fi + if ! [ -d /etc/lightdm ];then + systemctl set-default multi-user.target + ln -fs /lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@tty1.service + cat > /etc/systemd/system/getty@tty1.service.d/autologin.conf << EOF +[Service] +ExecStart= +ExecStart=-/sbin/agetty --autologin $USER --noclear %I \$TERM +EOF + fi } install_recording_service() { @@ -219,9 +231,11 @@ install_caddy() { apt -qq update apt install -qqy caddy=2.4.5 && apt-mark hold caddy systemctl enable --now caddy + usermod -aG pi caddy else echo "Caddy is installed" systemctl enable --now caddy + usermod -aG pi caddy fi } @@ -232,6 +246,7 @@ install_Caddyfile() { cp /etc/caddy/Caddyfile{,.original} fi php_version="$(awk -F'php' '{print $3}' <(ls -l $(which /etc/alternatives/php)))" + if ! [ -z ${CADDY_PWD} ];then HASHWORD=$(caddy hash-password -plaintext ${CADDY_PWD}) cat << EOF > /etc/caddy/Caddyfile http://localhost http://birdnetpi.local ${BIRDNETPI_URL} { @@ -253,6 +268,17 @@ http://localhost http://birdnetpi.local ${BIRDNETPI_URL} { php_fastcgi unix//run/php/php${php_version}-fpm.sock } EOF + else + cat << EOF > /etc/caddy/Caddyfile +http://localhost http://birdnetpi.local ${BIRDNETPI_URL} { + root * ${EXTRACTED} + file_server browse + reverse_proxy /stream localhost:8000 + php_fastcgi unix//run/php/php${php_version}-fpm.sock +} +EOF + fi + if [ ! -z ${EXTRACTIONLOG_URL} ];then cat << EOF >> /etc/caddy/Caddyfile @@ -296,7 +322,7 @@ Requires=network-online.target Restart=always RestartSec=3 Type=simple -ExecStart=/bin/bash -c "/usr/bin/avahi-publish -a -R %I $(avahi-resolve -4 -n %H.local | cut -f 2)" +ExecStart=/bin/bash -c "/usr/bin/avahi-publish -a -R %I $(hostname -I |cut -d' ' -f1)" [Install] WantedBy=multi-user.target @@ -416,25 +442,6 @@ EOF fi } -install_edit_birdnet_conf() { - cat << EOF > /etc/systemd/system/edit_birdnet_conf.service -[Unit] -Description=Edit birdnet.conf - -[Service] -Restart=on-failure -RestartSec=3 -Type=simple -User=pi -Environment=TERM=xterm-256color -ExecStart=/usr/local/bin/gotty -w -p 9898 --title-format "Edit birdnet.conf" nano /home/pi/BirdNET-Pi/birdnet.conf - -[Install] -WantedBy=multi-user.target -EOF -} - - install_icecast() { if ! which icecast2;then echo "Installing IceCast2" @@ -486,11 +493,13 @@ EOF } install_nomachine() { - if [ ! -d /usr/share/NX ];then + if [ ! -d /usr/share/NX ] && [ -d /etc/lightdm ];then echo "Installing NoMachine" curl -s -o ${HOME}/nomachine.deb -O "${nomachine_url}" apt install -y ${HOME}/nomachine.deb rm -f ${HOME}/nomachine.deb + echo "Enabling VNC" + systemctl enable --now vncserver-x11-serviced.service fi } @@ -507,6 +516,7 @@ install_cleanup_cron() { install_selected_services() { set_hostname + update_system install_scripts install_birdnet_analysis @@ -529,7 +539,6 @@ install_selected_services() { install_mariadb install_spectrogram_service install_chart_viewer_service - install_edit_birdnet_conf install_pushed_notifications if [ ! -z "${ICE_PWD}" ];then diff --git a/scripts/overview.php b/scripts/overview.php index b583760..e2912db 100644 --- a/scripts/overview.php +++ b/scripts/overview.php @@ -1,6 +1,7 @@ select_db('birds'); @@ -119,7 +120,13 @@ while($rows=$mostrecent ->fetch_assoc())

Today's Top 10 Species

- +"; +} else { + echo "

No Detections For Today

"; +} +?>

Currently Analyzing

diff --git a/scripts/spectrogram.php b/scripts/spectrogram.php index 57b9496..f5d7560 100644 --- a/scripts/spectrogram.php +++ b/scripts/spectrogram.php @@ -2,4 +2,4 @@ header("refresh: 15;"); echo ""; ?> - + diff --git a/scripts/tmux b/scripts/tmux deleted file mode 100755 index fc178d4..0000000 Binary files a/scripts/tmux and /dev/null differ diff --git a/scripts/update_services.sh b/scripts/update_services.sh index 5fbf27c..75dbcb0 100755 --- a/scripts/update_services.sh +++ b/scripts/update_services.sh @@ -16,10 +16,13 @@ set_hostname() { echo "Setting hostname to 'birdnetpi'" hostnamectl set-hostname birdnetpi sed -i 's/raspberrypi/birdnetpi/g' /etc/hosts - sed -i 's/localhost$/localhost birdnetpi.local/g' /etc/hosts fi } +update_system() { + apt update && apt -y upgrade +} + install_scripts() { echo "Installing BirdNET-Pi scripts to /usr/local/bin" ln -sf ${my_dir}/* /usr/local/bin/ @@ -185,6 +188,16 @@ install_alsa() { apt install -qqy pulseaudio echo "PulseAudio installed" fi + if ! [ -d /etc/lightdm ];then + systemctl set-default multi-user.target + ln -fs /lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@tty1.service + cat > /etc/systemd/system/getty@tty1.service.d/autologin.conf << EOF +[Service] +ExecStart= +ExecStart=-/sbin/agetty --autologin $USER --noclear %I \$TERM +EOF + fi + } install_recording_service() { @@ -229,6 +242,7 @@ install_Caddyfile() { cp /etc/caddy/Caddyfile{,.original} fi php_version="$(awk -F'php' '{print $3}' <(ls -l $(which /etc/alternatives/php)))" + if ! [ -z ${CADDY_PWD} ];then HASHWORD=$(caddy hash-password -plaintext ${CADDY_PWD}) cat << EOF > /etc/caddy/Caddyfile http://localhost http://birdnetpi.local ${BIRDNETPI_URL} { @@ -250,6 +264,17 @@ http://localhost http://birdnetpi.local ${BIRDNETPI_URL} { php_fastcgi unix//run/php/php${php_version}-fpm.sock } EOF + else + cat << EOF > /etc/caddy/Caddyfile +http://localhost http://birdnetpi.local ${BIRDNETPI_URL} { + root * ${EXTRACTED} + file_server browse + reverse_proxy /stream localhost:8000 + php_fastcgi unix//run/php/php${php_version}-fpm.sock +} +EOF + fi + if [ ! -z ${EXTRACTIONLOG_URL} ];then cat << EOF >> /etc/caddy/Caddyfile @@ -291,8 +316,9 @@ Requires=network-online.target [Service] Restart=always +RestartSec=3 Type=simple -ExecStart=/bin/bash -c "/usr/bin/avahi-publish -a -R %I $(avahi-resolve -4 -n %H.local | cut -f 2)" +ExecStart=/bin/bash -c "/usr/bin/avahi-publish -a -R %I $(hostname -I |cut -d' ' -f1)" [Install] WantedBy=multi-user.target @@ -411,25 +437,6 @@ EOF fi } -install_edit_birdnet_conf() { - cat << EOF > /etc/systemd/system/edit_birdnet_conf.service -[Unit] -Description=Edit birdnet.conf - -[Service] -Restart=on-failure -RestartSec=3 -Type=simple -User=pi -Environment=TERM=xterm-256color -ExecStart=/usr/local/bin/gotty -w -p 9898 --title-format "Edit birdnet.conf" nano /home/pi/BirdNET-Pi/birdnet.conf - -[Install] -WantedBy=multi-user.target -EOF -} - - install_icecast() { if ! which icecast2;then echo "Installing IceCast2" @@ -481,11 +488,13 @@ EOF } install_nomachine() { - if [ ! -d /usr/share/NX ];then + if [ ! -d /usr/share/NX ] && [ -d /etc/lightdm ];then echo "Installing NoMachine" curl -s -o ${HOME}/nomachine.deb -O "${nomachine_url}" apt install -y ${HOME}/nomachine.deb rm -f ${HOME}/nomachine.deb + echo "Enabling VNC" + systemctl enable --now vncserver-x11-serviced.service fi } @@ -502,6 +511,7 @@ install_cleanup_cron() { install_selected_services() { set_hostname + update_system install_scripts install_birdnet_analysis @@ -524,7 +534,6 @@ install_selected_services() { install_mariadb install_spectrogram_service install_chart_viewer_service - install_edit_birdnet_conf install_pushed_notifications if [ ! -z "${ICE_PWD}" ];then diff --git a/scripts/viewday.php b/scripts/viewday.php index 4b4cd2d..c79eaf1 100644 --- a/scripts/viewday.php +++ b/scripts/viewday.php @@ -1,6 +1,7 @@ select_db('birds'); @@ -64,7 +65,13 @@ table,th,td { - +"; +} else { + echo "

No Detections For Today

"; +} +?>
diff --git a/scripts/write_advanced.php b/scripts/write_advanced.php new file mode 100644 index 0000000..3be99c4 --- /dev/null +++ b/scripts/write_advanced.php @@ -0,0 +1,60 @@ + + diff --git a/scripts/write_config.php b/scripts/write_config.php new file mode 100644 index 0000000..6c99345 --- /dev/null +++ b/scripts/write_config.php @@ -0,0 +1,46 @@ + + diff --git a/version.md b/version.md index d8a0d2e..4a1942b 100644 --- a/version.md +++ b/version.md @@ -1,3 +1,9 @@ +# main v.11 +- New "Reconfigure System" GUI +- labels.txt language support for 20+ languages + - Tool in `birdnet-pi-config` for now + - Added German top.html and menu.html + # main v.10 & pre-installed image notes - New "BirdWeather" Chromium App (Pre-install image) - New Infographics _chart_viewer.service_ (courtesy of @CaiusX)