diff --git a/.gitignore b/.gitignore index 50425de..d956f22 100644 --- a/.gitignore +++ b/.gitignore @@ -4,8 +4,6 @@ model/BirdNET_Soundscape_Model.pkl .vscode datasets/ birdnet.conf -miniforge -scripts/install_miniforge.sh IdentifiedSoFar.txt IdentifiedSoFar.txt.bak Birders_Guide_Installer_Configuration.txt diff --git a/Birders_Guide_Installer.sh b/Birders_Guide_Installer.sh index dfa2f1e..6d102db 100755 --- a/Birders_Guide_Installer.sh +++ b/Birders_Guide_Installer.sh @@ -1,10 +1,11 @@ #!/usr/bin/env bash set -e +USER=pi +HOME=/home/pi my_dir=${HOME}/BirdNET-Pi branch=main trap '${my_dir}/scripts/dump_logs.sh && exit' EXIT SIGHUP SIGINT - if [ "$(uname -m)" != "aarch64" ];then echo "BirdNET-Pi requires a 64-bit OS. It looks like your operating system is using $(uname -m), @@ -14,63 +15,6 @@ information" exit 1 fi -install_zram_swap() { - echo - echo "Configuring zram.service" - sudo touch /etc/modules-load.d/zram.conf - echo 'zram' | sudo tee /etc/modules-load.d/zram.conf - sudo touch /etc/modprobe.d/zram.conf - echo 'options zram num_devices=1' | sudo tee /etc/modprobe.d/zram.conf - sudo touch /etc/udev/rules.d/99-zram.rules - echo 'KERNEL=="zram0", ATTR{disksize}="4G",TAG+="systemd"' \ - | sudo tee /etc/udev/rules.d/99-zram.rules - sudo touch /etc/systemd/system/zram.service - echo "Installing zram.service" - cat << EOF | sudo tee /etc/systemd/system/zram.service &> /dev/null -[Unit] -Description=Swap with zram -After=multi-user.target - -[Service] -Type=oneshot -RemainAfterExit=true -ExecStartPre=/sbin/mkswap /dev/zram0 -ExecStart=/sbin/swapon /dev/zram0 -ExecStop=/sbin/swapoff /dev/zram0 - -[Install] -WantedBy=multi-user.target -EOF - sudo systemctl enable zram - echo - echo "Installing stage 2 installation script now." - cd ~ - curl -s -O "https://raw.githubusercontent.com/mcguirepr89/BirdNET-Pi/${branch}/Birders_Guide_Installer.sh" - chmod +x Birders_Guide_Installer.sh - cat << EOF | sudo tee /etc/systemd/user/birdnet-system-installer.service &> /dev/null -[Unit] -Description=A BirdNET-Pi Installation Script Service -After=graphical.target network-online.target - -[Service] -Type=simple -Restart=on-failure -RestartSec=3s -ExecStart=lxterminal -e /home/pi/Birders_Guide_Installer.sh - -[Install] -WantedBy=default.target -EOF - systemctl --user enable birdnet-system-installer.service - echo - echo "Stage 1 complete" - touch ${HOME}/stage_1_complete - echo - echo "Rebooting the system in 5 seconds" - sleep 5 - sudo reboot -} - stage_1() { echo echo "Beginning Stage 1" @@ -84,15 +28,8 @@ stage_1() { echo "Installing git" sudo apt install -qqy git fi - ZRAM="$(swapon --show=SIZE,NAME | awk -FG '!/SIZE/ && /zram/ {print $1}')" - [ ! -z ${ZRAM} ] || ZRAM=0 - if [ ${ZRAM} -lt 4 ];then - install_zram_swap - else - echo "Stage 1 complete" - stage_2 - exit - fi + touch ${HOME}/stage_1_complete + echo "Stage 1 complete" } stage_2() { @@ -106,62 +43,32 @@ stage_2() { echo "Connected!" echo if [ ! -d ${my_dir} ];then - cd ~ || exit 1 + cd ${HOME} || exit 1 echo "Cloning the BirdNET-Pi repository $branch branch into your home directory" - git clone -b ${branch} https://github.com/mcguirepr89/BirdNET-Pi.git ~/BirdNET-Pi + git clone -b ${branch} https://github.com/mcguirepr89/BirdNET-Pi.git ${HOME}/BirdNET-Pi else cd ${my_dir} && git checkout ${branch} fi - if [ -f ${my_dir}/Birders_Guide_Installer_Configuration.txt ];then - echo + source ${my_dir}/Birders_Guide_Installer_Configuration.txt + if [ -z ${LATITUDE} ] || [ -z ${LONGITUDE} ] || [ -z ${CADDY_PWD} ] || [ -z ${ICE_PWD} ] || [ -z ${DB_PWD} ] || [ -z ${DB_ROOT_PWD} ];then echo echo "Follow the instructions to fill out the LATITUDE and LONGITUDE variables and set the passwords for the live audio stream. Save the file after editing and then close the Mouse Pad editing window to continue." - if ( env | grep SSH_CONNECTION &> /dev/null );then - editor=nano + echo + if [ -z "$SSH_CONNECTION" ];then + EDITOR=mousepad else - editor=mousepad + EDITOR=nano fi - $editor ${my_dir}/Birders_Guide_Installer_Configuration.txt - while pgrep $editor &> /dev/null;do + $EDITOR ${my_dir}/Birders_Guide_Installer_Configuration.txt + while pgrep $EDITOR &> /dev/null;do sleep 1 done source ${my_dir}/Birders_Guide_Installer_Configuration.txt || exit 1 - else - echo "Something went wrong. I can't find the configuration file." - exit 1 - fi - - if [ -z ${LATITUDE} ] || [ -z ${LONGITUDE} ] || [ -z ${CADDY_PWD} ] || [ -z ${ICE_PWD} ] || [ -z ${DB_PWD} ] || [ -z ${DB_ROOT_PWD} ];then - echo - echo - echo "It looks like you haven't filled out the Birders_Guide_Installer_Configuration.txt file -completely. - -Open that file to edit it. (Go to the folder icon in the top left and look for the \"BirdNET-Pi\" -folder and double-click the file called \"Birders_Guide_Installer_Configuration.txt\" -Enter the latitude and longitude of where the BirdNET-Pi will be. -You can find this information at https://maps.google.com - -Find your location on the map and right click to find your coordinates. -After you have filled out the configuration file, you can re-run this script. Just do the exact -same things you did to start this (copying and pasting from the Wiki) to try again. -Press Enter to close this window. -Good luck!" - read - exit 1 fi echo "Installing the BirdNET-Pi configuration file." - [ -f ${my_dir}/soundcard_params.txt ] || touch ${my_dir}/soundcard_params.txt - SOUND_PARAMS="${HOME}/BirdNET-Pi/soundcard_params.txt" - SOUND_CARD="$(sudo -u pi aplay -L \ - | grep -e '^hw' \ - | cut -d, -f1 \ - | grep -ve 'vc4' -e 'Head' -e 'PCH' \ - | uniq)" - script -c "arecord -D ${SOUND_CARD} --dump-hw-params" -a ${SOUND_PARAMS} &> /dev/null install_birdnet_config || exit 1 echo "Installing BirdNET-Lite" if ${my_dir}/scripts/install_birdnet.sh << EOF ; then @@ -242,9 +149,9 @@ DO_RECORDING=y ## will be web-hosted. If you do not own a domain, or would just prefer to keep ## the BirdNET-Pi on your local network, keep this EMPTY. -BIRDNETPI_URL= -EXTRACTIONLOG_URL= -BIRDNETLOG_URL= +BIRDNETPI_URL=${BIRDNETPI_URL} +EXTRACTIONLOG_URL=${EXTRACTIONLOG_URL} +BIRDNETLOG_URL=${BIRDNETLOG_URL} ## CADDY_PWD is the plaintext password (that will be hashed) and used to access ## the "Processed" directory and live audio stream. This MUST be set if you @@ -387,26 +294,10 @@ EOF [ -d /etc/birdnet ] || sudo mkdir /etc/birdnet sudo ln -sf ${my_dir}/birdnet.conf /etc/birdnet/birdnet.conf } -echo " -Welcome to the Birders Guide Installer script! - -The installer runs in two stages: -Stage 1 configures and enables the zRAM kernel module and allocates 4G - to its swapping size if needed. This will trigger a reboot. -Stage 1 also ensures the system is up to date. -Stage 2 guides you through configuring the essentials and installs the full BirdNET-Pi system." - - if [ ! -f ${HOME}/stage_1_complete ] ;then stage_1 + stage_2 else stage_2 - if [ -f ${HOME}/Birders_Guide_Installer.sh ];then - rm ${HOME}/Birders_Guide_Installer.sh - fi - rm ${HOME}/stage_1_complete - ${my_dir}/scripts/dump_logs.sh - systemctl --user disable --now birdnet-system-installer.service - sudo rm -f /etc/systemd/user/birdnet-system-installer.service fi diff --git a/Birders_Guide_Installer_Configuration.txt b/Birders_Guide_Installer_Configuration.txt index b2e0eed..78445fc 100644 --- a/Birders_Guide_Installer_Configuration.txt +++ b/Birders_Guide_Installer_Configuration.txt @@ -45,3 +45,10 @@ DB_ROOT_PWD= # detections. PUSHED_APP_SECRET= PUSHED_APP_KEY= + +# If you own your own domain, you can input that here to have caddy register +# TLS certificates for the web interface + +BIRDNETPI_URL= +BIRDNETLOG_URL= +EXTRACTIONLOG_URL= diff --git a/LICENSE b/LICENSE index 5393dd4..2820ecf 100644 --- a/LICENSE +++ b/LICENSE @@ -365,7 +365,7 @@ Section 8 -- Interpretation. processes of any jurisdiction or authority. ============================================================================= -Caddy uses the Apache License Version 2.0 +Caddy, and Adminer use the Apache License Version 2.0 ============================================================================= Apache License Version 2.0, January 2004 diff --git a/README.md b/README.md index b872175..ae7e9c9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # BirdNET-Pi - + A realtime acoustic bird classification system for the Raspberry Pi 4B @@ -32,15 +32,7 @@ The BirdNET-Pi project is built on the [TFLite version of BirdNET](https://githu The system can be installed with: ``` -curl -s https://raw.githubusercontent.com/mcguirepr89/BirdNET-Pi/main/Birders_Guide_Installer.sh | bash -``` - -The script first enables and configures the zRAM kernel module for swapping, and reboots. -After the reboot, the configuration file is opened for editing. Here, you will input your latitude and longitude and will set a few passwords to protect your Pi. When the installation has finished, the BirdNET-Pi is ready to start collecting and analyzing data on the next boot. - -If you have trouble with the installation script, you can cancel and rerun the installer: -``` -~/BirdNET-Pi/Birders_Guide_Installer.sh +curl -s https://raw.githubusercontent.com/mcguirepr89/BirdNET-Pi/newinstaller/newinstaller.sh | bash ``` ## Access diff --git a/birdnet.conf-defaults b/birdnet.conf-defaults index 118e0d4..0ba5c3c 100644 --- a/birdnet.conf-defaults +++ b/birdnet.conf-defaults @@ -1,91 +1,75 @@ ################################################################################ -# Configuration settings for BirdNET as a service # +# Configuration settings for BirdNET-Pi # ################################################################################ -INSTALL_DATE="$(date "+%D")" -#___________The four variables below are the only that are required.___________# -## BIRDNET_USER should be the non-root user systemd should use to execute each -## service. +############ CHANGE THE LATITUDE AND LONGITUDE TO STATIC VALUES ################ -BIRDNET_USER= + +## LATITUDE and LONGITUDE are self-explanatroy. Find them easily at +## maps.google.com. +## Example: these coordinates would indicate the Eiffel Tower in Paris, France. +## LATITUDE=48.858 +## LONGITUDE=2.294 + +## These are input as shell substitutions so that this will work out of the box. +## It guesses your latitude and longitude based off of your network information. +## THESE SHOULD BE CHANGED TO STATIC NUMBERS!!!! +LATITUDE="$(curl -s4 ifconfig.co/json | awk '/lat/ {print $2}' | tr -d ',')" +LONGITUDE="$(curl -s4 ifconfig.co/json | awk '/lon/ {print $2}' | tr -d ',')" ## RECS_DIR is the location birdnet_analysis.service will look for the data-set ## it needs to analyze. Be sure this directory is readable and writable for ## the BIRDNET_USER. If you are going to be accessing a remote data-set, you ## still need to set this, as this will be where the remote directory gets -## mounted locally. +## mounted locally. -RECS_DIR= +RECS_DIR=/home/pi/BirdSongs -## LATITUDE and LONGITUDE are self-explanatroy. Find them easily at -## maps.google.com. Only go to the thousanths place for these variables -## Example: these coordinates would indicate the Eiffel Tower in Paris, France. -## LATITUDE=48.858 -## LONGITUDE=2.294 - -LATITUDE= -LONGITUDE= - -################################################################################ -#------------------------------ Extraction Service ---------------------------# -#__________________The variable below can be set to enable the ________________# -#______________________________ extraction.service ____________________________# - -# Keep this EMPTY if you do not want this device to perform the extractions # - -## DO_EXTRACTIONS is simply a setting for enabling the extraction.service. -## Set this to Y or y to enable extractions. - -DO_EXTRACTIONS= - -################################################################################ -#----------------------------- Recording Service ----------------------------# -#____________________The variable below can be set to enable __________________# -#________________________the birdnet_recording.service ________________________# - -# Keep this EMPTY if you do not want this device to perform the recording. # - -## DO_RECORDING is simply a setting for enabling the 24/7 -## birdnet_recording.service. -## Set this to Y or y to enable recording. - -DO_RECORDING= - -################################################################################ -#----------------------- Web-hosting/Caddy File-server -----------------------# -#_______The two variables below can be set to enable internet access___________# -#____________to your data,(e.g., extractions, raw data, live___________________# -#______________audio stream, BirdNET.selection.txt files)______________________# - -# Leave these EMPTY if you do not want to enable web access # - -## BIRDNETPI_URL is the URL where the extractions, data-set, and live-stream -## will be web-hosted. If you do not own a domain, or would just prefer to keep -## BirdNET-Pi on your local network, keep this empty. - -BIRDNETPI_URL= +#----------------------- Web Interface User Password ------------------------# +#____________________The variable below sets the 'birdnet'_____________________# +#___________________user password for the live audio stream,___________________# +#_________________web tools, system info, and processed files__________________# ## CADDY_PWD is the plaintext password (that will be hashed) and used to access -## the "Processed" directory and live audio stream. This MUST be set if you -## choose to enable this feature. +## certain parts of the web interface -CADDY_PWD= +CADDY_PWD=changeme + +#------------------------- MariaDB User Passwords ---------------------------# +#_____________The variables below set the 'birder' and 'root'__________________# +#_______________________user passwords for the MariaDB_________________________# + +## DB_PWD is for the 'birder' user +DB_PWD=changeme +## DB_ROOT_PWD is for the 'root' user +DB_ROOT_PWD=changeme -################################################################################ #------------------------- Live Audio Stream --------------------------------# #_____________The variable below configures/enables the live___________________# #_____________________________audio stream.____________________________________# -# Keep this EMPTY if you do not wish to enable the live stream # -# or if this device is not doing the recording # ## ICE_PWD is the password that icecast2 will use to authenticate ffmpeg as a ## trusted source for the stream. You will never need to enter this manually ## anywhere other than here. -ICE_PWD= +ICE_PWD=changeme + +#----------------------- Web-hosting/Caddy File-server -----------------------# +#________The four variables below can be set to enable internet access_________# +#____________to your data,(e.g., extractions, raw data, live___________________# +#______________audio stream, BirdNET.selection.txt files)______________________# + + +## BIRDNETPI_URL is the URL where the extractions, data-set, and live-stream +## will be web-hosted. If you do not own a domain, or would just prefer to keep +## the BirdNET-Pi on your local network, keep this EMPTY. + +BIRDNETPI_URL= +EXTRACTIONLOG_URL= +BIRDNETLOG_URL= + -################################################################################ #------------------- Mobile Notifications via Pushed.co ---------------------# #____________The two variables below enable mobile notifications_______________# #_____________See https://pushed.co/quick-start-guide to get___________________# @@ -99,6 +83,9 @@ PUSHED_APP_KEY= PUSHED_APP_SECRET= ################################################################################ +#-------------------------------- Defaults ----------------------------------# +################################################################################ + #------------------------------- NoMachine ----------------------------------# #_____________The variable below can be set include NoMachine__________________# #_________________remote desktop software to be installed._____________________# @@ -109,14 +96,27 @@ PUSHED_APP_SECRET= ## NoMachine alongside the BirdNET-Pi for remote desktop access. This in- ## staller assumes personal use. Please reference the LICENSE file included ## in this repository for more information. -## Set this to Y or y to install NoMachine alongside the BirdNET-Pi +## Set this to Y or y to install NoMachine alongside the BirdNET-Lite -INSTALL_NOMACHINE= +INSTALL_NOMACHINE=y -################################################################################ -#-------------------------------- Defaults ----------------------------------# -#______The seven variables below are default settings that you (probably)______# -#__________________don't need to change at all, but can._______________________# +# +#------------------------------ Extraction Service ---------------------------# + +## DO_EXTRACTIONS is simply a setting for enabling the extraction.service. +## Set this to Y or y to enable extractions. + +DO_EXTRACTIONS=y + +#----------------------------- Recording Service ----------------------------# +#____________________The variable below can be set to enable __________________# +#________________________the birdnet_recording.service ________________________# + +## DO_RECORDING is simply a setting for enabling the 24/7 +## birdnet_recording.service. +## Set this to Y or y to enable recording. + +DO_RECORDING=y ## REC_CARD is the sound card you would want the birdnet_recording.service to ## use. This setting is irrelevant if you are not planning on doing data @@ -129,7 +129,7 @@ INSTALL_NOMACHINE= ## devices from the output of running 'aplay -L' REC_CARD=default - + ## PROCESSED is the directory where the formerly 'Analyzed' files are moved ## after extractions have been made from them. This includes both WAVE and ## BirdNET.selection.txt files. @@ -166,44 +166,29 @@ CONFIDENCE=0.7 SENSITIVITY=1.25 -################################################################################ -#------------------------------ Auto-Generated ------------------------------# -#_____________________The variables below are auto-generated___________________# -#______________________________during installation_____________________________# - ## CHANNELS holds the variabel that corresponds to the number of channels the ## sound card supports. -CHANNELS= - -# Don't touch the variables below - -## SYSTEMD_MOUNT is created from the RECS_DIR variable to comply with systemd -## mount naming requirements. - -SYSTEMD_MOUNT=$(echo ${RECS_DIR#/} | tr / -).mount +CHANNELS=2 ## VENV is the virtual environment where the the BirdNET python build is found, ## i.e, VENV is the virtual environment miniforge built for BirdNET. -VENV=$(dirname ${my_dir})/miniforge/envs/birdnet - -################################################################################ -#---------------------------------- Testing -----------------------------------# -#_____________These variables are for testing. Please don't touch______________# -#_______________them if you are not testing these features.____________________# - -# To test different values for RECORDING_LENGTH, first: -# 1) stop the birdnet_recording.service: -#### run: `sudo systemctl stop birdnet_recording.service` -# 2) remove any remaining audio files in the day's recording directory: -#### Example: to remove recordings for Saturday, October 2nd, 2021, you would -#### run: `rm -rf /home/pi/BirdSongs/October-2021/02-Saturday/*` -# 3) restart the birdnet_recording.service: -#### run: `sudo systemctl restart birdnet_recording.service` +VENV=/home/pi/BirdNET-Pi/birdnet +## RECORDING_LENGTH sets the length of the recording that BirdNET-Lite will analyze. RECORDING_LENGTH= +## EXTRACTION_LENGTH sets the length of the audio extractions that will be made +## from each BirdNET-Lite detection. EXTRACTION_LENGTH= +## BIRDNET_USER should be the non-root user systemd should use to execute each +## service. + +BIRDNET_USER=pi + + +## These are just for debugging LAST_RUN= +THIS_RUN= diff --git a/homepage/images/version.svg b/homepage/images/version.svg new file mode 100644 index 0000000..4aac097 --- /dev/null +++ b/homepage/images/version.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/homepage/style.css b/homepage/style.css new file mode 100644 index 0000000..5ef8516 --- /dev/null +++ b/homepage/style.css @@ -0,0 +1,103 @@ +/* style sheet */ +* { + box-sizing: border-box; +} + +.row { + display: flex; +} + +.column { + flex: 50%; + padding-right: 5px; +} + +table { + margin: 0 auto; + font-size: large; + border-collapse: collapse; + border-spacing: 0; + width: 100%; + border: 1px solid black; +} + +h1 { + text-align: center; + color: black; + font-size: xx-large; + font-family: 'Gill Sans', 'Gill Sans MT', + ' Calibri', 'Trebuchet MS', 'sans-serif'; +} + +h2 { + text-align: center; + color: black; + font-size: large; + font-family: 'Gill Sans', 'Gill Sans MT', + ' Calibri', 'Trebuchet MS', 'sans-serif'; +} + +td { + background-color: rgb(119, 196, 135); + border: 1px solid black; +} + +th, +td { + font-weight: bold; + border: 1px solid black; + padding: 10px; + text-align: center; + background-color: rgb(219, 296, 235); +} + +@media screen and (max-width: 800px) { + .column { + float: none; + width: 100%; + } + table { + margin: 0 auto; + font-size: medium; + border-collapse: collapse; + border-spacing: 1; + width: 100%; + border: 1px solid black; + } + + h1 { + text-align: center; + color: black; + font-size: large; + font-family: 'Gill Sans', 'Gill Sans MT', + ' Calibri', 'Trebuchet MS', 'sans-serif'; + } + + h2 { + text-align: center; + color: black; + font-size: large; + font-family: 'Gill Sans', 'Gill Sans MT', + ' Calibri', 'Trebuchet MS', 'sans-serif'; + } + + td { + background-color: rgb(119, 196, 135); + border: 1px solid black; + } + + th, + td { + font-weight: bold; + border: 1px solid black; + padding: 10px; + text-align: center; + } +} + +td { + font-weight: lighter; +} +body::-webkit-scrollbar { + display:none +} diff --git a/homepage/top.html b/homepage/top.html index f56035e..36b2379 100644 --- a/homepage/top.html +++ b/homepage/top.html @@ -22,6 +22,11 @@ body { position: absolute; top: 0px; left: 0px; + } + #content2 img { + position: absolute; + top: 0px; + right: 0px; } @@ -38,5 +43,8 @@ body { System Info | Tools
+