Merge branch 'rpi4' into patch-3

This commit is contained in:
mcguirepr89
2021-10-08 12:35:13 -04:00
committed by GitHub
17 changed files with 234 additions and 85 deletions
+8 -3
View File
@@ -107,7 +107,7 @@ stage_2() {
if [ ! -d ${my_dir} ];then if [ ! -d ${my_dir} ];then
cd ~ || exit 1 cd ~ || exit 1
echo "Cloning the BirdNET-Lite repository in your home directory" echo "Cloning the BirdNET-Lite repository in your home directory"
git clone -b rpi4 https://github.com/mcguirepr89/BirdNET-Lite.git ~/BirdNET-Lite git clone https://github.com/mcguirepr89/BirdNET-Lite.git ~/BirdNET-Lite
fi fi
if [ -f ${my_dir}/Birders_Guide_Installer_Configuration.txt ];then if [ -f ${my_dir}/Birders_Guide_Installer_Configuration.txt ];then
@@ -116,8 +116,13 @@ stage_2() {
echo "Follow the instructions to fill out the LATITUDE and LONGITUDE variables 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 set the passwords for the live audio stream. Save the file after editing
and then close the Mouse Pad editing window to continue." and then close the Mouse Pad editing window to continue."
mousepad ${my_dir}/Birders_Guide_Installer_Configuration.txt &> /dev/null if ( env | grep SSH_CONNECTION &> /dev/null );then
while pgrep mouse &> /dev/null;do editor=nano
else
editor=mousepad
fi
$editor ${my_dir}/Birders_Guide_Installer_Configuration.txt &> /dev/null
while pgrep $editor &> /dev/null;do
sleep 1 sleep 1
done done
source ${my_dir}/Birders_Guide_Installer_Configuration.txt || exit 1 source ${my_dir}/Birders_Guide_Installer_Configuration.txt || exit 1
+4
View File
@@ -5,6 +5,7 @@ source /etc/birdnet/birdnet.conf
# Document this run's birdnet.conf settings # Document this run's birdnet.conf settings
# Make a temporary file to compare the current birdnet.conf with # Make a temporary file to compare the current birdnet.conf with
# the birdnet.conf as it was the last time this script was called # the birdnet.conf as it was the last time this script was called
my_dir=$(realpath $(dirname $0))
make_thisrun() { make_thisrun() {
sleep .4 sleep .4
awk '!/#/ && !/^$/ {print}' /etc/birdnet/birdnet.conf \ awk '!/#/ && !/^$/ {print}' /etc/birdnet/birdnet.conf \
@@ -76,6 +77,7 @@ run_analysis() {
cd ${HOME}/BirdNET-Lite || exit 1 cd ${HOME}/BirdNET-Lite || exit 1
for i in "${files[@]}";do for i in "${files[@]}";do
echo "${1}/${i}" > ./analyzing_now.txt
[ -z ${RECORDING_LENGTH} ] && RECORDING_LENGTH=12 [ -z ${RECORDING_LENGTH} ] && RECORDING_LENGTH=12
[ ${RECORDING_LENGTH} == "60" ] && RECORDING_LENGTH=01:00 [ ${RECORDING_LENGTH} == "60" ] && RECORDING_LENGTH=01:00
FILE_LENGTH="$(ffmpeg -i ${1}/${i} 2>&1 | awk -F. '/Duration/ {print $1}' | cut -d':' -f3-4)" FILE_LENGTH="$(ffmpeg -i ${1}/${i} 2>&1 | awk -F. '/Duration/ {print $1}' | cut -d':' -f3-4)"
@@ -150,6 +152,8 @@ run_birdnet() {
run_analysis "${1}" run_analysis "${1}"
} }
date
if [ $(find ${RECS_DIR} -maxdepth 1 -name '*wav' | wc -l) -gt 0 ];then if [ $(find ${RECS_DIR} -maxdepth 1 -name '*wav' | wc -l) -gt 0 ];then
run_birdnet "${RECS_DIR}" run_birdnet "${RECS_DIR}"
fi fi
+80 -36
View File
@@ -1,11 +1,13 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# BirdNET Stats Page # BirdNET Stats Page
trap 'setterm --cursor on' EXIT trap 'setterm --cursor on && exit' EXIT
trap 'rm -f "${TMP_FILE}" && exit' EXIT
source /etc/birdnet/birdnet.conf source /etc/birdnet/birdnet.conf
setterm --cursor off setterm --cursor off
TMP_FILE="$(mktemp)"
while true;do while true;do
cat << "EOF" cat << "EOF"
.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+. .+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.
( _ ____ __ _ ) ( _ ____ __ _ )
) |_)o.__||\ ||_ |__(_ __|_ _ ._ _ |_) _ ._ _ .__|_ ( ) |_)o.__||\ ||_ |__(_ __|_ _ ._ _ |_) _ ._ _ .__|_ (
@@ -13,37 +15,79 @@ cat << "EOF"
) / | ( ) / | (
"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+" "+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"
EOF EOF
if [ "$(find ${EXTRACTED} -name '*.wav' | wc -l)" -ge 1 ];then if [ "$(find ${EXTRACTED} -name '*.wav' | wc -l)" -ge 1 ] &> /dev/null;then
a=$( find "${EXTRACTED}" -name '*.wav' \ a=$( find "${EXTRACTED}" -name '*.wav' \
| awk -F "/" '{print $NF}' \ | awk -F "/" '{print $NF}' \
| cut -d'-' -f1 \ | cut -d'-' -f1 \
| sort -n \ | sort -n \
| tail -n1 ) | tail -n1 )
else else
a=0 a=0
fi fi
echo echo
if [ "${a}" -ge "1" ];then if [ "${a}" -ge "1" ];then
SOFAR=$(($(wc -l ${IDFILE}| cut -d' ' -f1)/2)) SOFAR=$(($(wc -l ${IDFILE}| cut -d' ' -f1)/2))
else else
SOFAR=0 SOFAR=0
fi fi
echo " -$a detections so far" if [ $SOFAR = 1 ];then
echo verbage=detection
echo " -$SOFAR species identified so far" else
echo verbage=detections
if [ ${a} -ge 1 ];then fi
while read -r line;do echo " -$a $verbage so far"
SPECIES="$(echo "${line}" | awk -F: '/Common Name/ {print $2}')" echo
SPECIES=${SPECIES// /_} echo " -$SOFAR species identified so far"
SPECIES=${SPECIES/_} echo
[ -z ${SPECIES} ] && continue if [ "${SOFAR}" -ge "1" ];then
DETECTIONS="$(ls -1 ${EXTRACTED}/By_Date/*/${SPECIES}| wc -l)" MOST_RECENT="$(find ${EXTRACTED}/By_Date/$(date +%Y-%m-%d) \
echo -e " | $line # of detections so far: ${DETECTIONS}\n" | sort -t"%" -rk2 \
done < ${IDFILE} | head -n1 \
fi | cut -d'/' -f8)"
echo AT_TIME="$(find ${EXTRACTED}/By_Date/$(date +%Y-%m-%d) \
echo -n "Listening since "${INSTALL_DATE}"" | sort -t"%" -rk2 \
sleep 20 | head -n1 \
clear | rev \
done | cut -d'-' -f1 \
| rev \
| cut -d'.' -f1)"
echo " -Most recent species detection: ${MOST_RECENT//_/ } at ${AT_TIME}"
echo
fi
if [ ${a} -ge 1 ];then
while read -r line;do
# Get species name
SPECIES="$(echo "${line}" | awk -F: '/Common Name/ {print $2}')"
SPECIES="${SPECIES// /_}"
SPECIES="$(echo ${SPECIES/_} | tr -d "'")"
[ -z ${SPECIES} ] && continue
# Get all detection files
ALL_DETECTION_FILES="$(find ${EXTRACTED}/By_Date/*/${SPECIES} -name '*.wav')"
ALL_DETECTION_FILES="$(echo ${ALL_DETECTION_FILES[@]} | tr ' ' '\n')"
# Parse highest confidence score
MAX_SCORE="$(echo "${ALL_DETECTION_FILES}"| awk -F% '{print $1}')"
MAX_SCORE="$(echo "${MAX_SCORE[@]}" | rev |cut -d"-" -f1|rev | sort -r | head -n1)"
# Set noun-plurality agreement for grammar
DETECTIONS="$(ls -1 ${EXTRACTED}/By_Date/*/${SPECIES} | wc -l)"
if [ ${DETECTIONS} = 1 ];then
verbage=detection
else
verbage=detections
fi
# Write results to temporary file
echo "${DETECTIONS} $verbage for ${SPECIES//_/ } | max conf ${MAX_SCORE}%"
done < "${IDFILE}" > ${TMP_FILE}
# Print temporary file sorted by # of detections
sort -rk1 -h "${TMP_FILE}"
fi
echo
echo -n "Listening since "${INSTALL_DATE}""
sleep 20
clear
done
+4
View File
@@ -0,0 +1,4 @@
<?php
shell_exec("/home/pi/BirdNET-Lite/scripts/clear_all_data.sh");
header('Location: http://birdnetsystem.local/scripts/index.html?success=true');
?>
+11 -26
View File
@@ -4,38 +4,23 @@
# you are okay will losing all the data that you've collected and processed # you are okay will losing all the data that you've collected and processed
# so far. # so far.
source /etc/birdnet/birdnet.conf source /etc/birdnet/birdnet.conf
echo "
This script removes all data that has been collected. It is tantamount to
starting all data-collection from scratch. Only run this if you are sure
you are okay with losing all the data that you've collected and processed
so far.
"
read -n1 -p "Are you sure you want to wipe away ALL data?" YN
echo
while true; do
case $YN in
[Yy]) break;;
*) echo "Exiting since you didn't answer with Y or y." && exit;;
esac
done
echo "Stopping services" echo "Stopping services"
sudo systemctl stop birdnet_recording.service sudo systemctl stop birdnet_recording.service
echo "Removing all data . . . " echo "Removing all data . . . "
sudo rm -drf "${RECS_DIR}" sudo rm -drf "${RECS_DIR}"
rm "${IDFILE}" rm "${IDFILE}"
echo "Recreating necessary directories" echo "Recreating necessary directories"
[ -d ${RECS_DIR} ] || mkdir -p ${RECS_DIR} [ -d ${RECS_DIR} ] || sudo -u ${BIRDNET_USER} mkdir -p ${RECS_DIR}
[ -d ${EXTRACTED} ] || mkdir -p ${EXTRACTED} [ -d ${EXTRACTED} ] || sudo -u ${BIRDNET_USER} mkdir -p ${EXTRACTED}
[ -d ${EXTRACTED}/By_Date ] || mkdir -p ${EXTRACTED}/By_Date [ -d ${EXTRACTED}/By_Date ] || sudo -u ${BIRDNET_USER} mkdir -p ${EXTRACTED}/By_Date
[ -d ${EXTRACTED}/By_Common_Name ] || mkdir -p ${EXTRACTED}/By_Common_Name [ -d ${EXTRACTED}/By_Common_Name ] || sudo -u ${BIRDNET_USER} mkdir -p ${EXTRACTED}/By_Common_Name
[ -d ${EXTRACTED}/By_Scientific_Name ] || mkdir -p ${EXTRACTED}/By_Scientific_Name [ -d ${EXTRACTED}/By_Scientific_Name ] || sudo -u ${BIRDNET_USER} mkdir -p ${EXTRACTED}/By_Scientific_Name
[ -d ${PROCESSED} ] || mkdir -p ${PROCESSED} sudo -u ${BIRDNET_USER} ln -s /home/pi/BirdNET-Lite/templates/index.html ${EXTRACTED}
cp ~/BirdNET-Lite/templates/index.html ${EXTRACTED}/ [ -d ${PROCESSED} ] || sudo -u ${BIRDNET_USER} mkdir -p ${PROCESSED}
[ -L ${EXTRACTED}/scripts ] || sudo -u ${BIRDNET_USER} ln -s /home/pi/BirdNET-Lite/scripts ${EXTRACTED}/
[ -L ${EXTRACTED}/spectrogram.php ] || sudo -u ${BIRDNET_USER} ln -s /home/pi/BirdNET-Lite/scripts/spectrogram.php ${EXTRACTED}
[ -L ${EXTRACTED}/spectrogram.sh ] || sudo -u ${BIRDNET_USER} ln -s /home/pi/BirdNET-Lite/scripts/spectrogram.sh ${EXTRACTED}
sudo -u ${BIRDNET_USER} cp ~/BirdNET-Lite/templates/index.html ${EXTRACTED}/
echo "Restarting services" echo "Restarting services"
sudo systemctl restart birdnet_recording.service sudo systemctl restart birdnet_recording.service
+4
View File
@@ -0,0 +1,4 @@
<?php
shell_exec("/home/pi/BirdNET-Lite/scripts/edit_birdnet.conf.sh");
header('Location: http://birdnetsystem.local:9898');
?>
+2
View File
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
sudo systemctl start edit_birdnet_conf.service
+28 -13
View File
@@ -3,12 +3,13 @@
#set -x #set -x
set -e set -e
# Keep track of the last executed command # Keep track of the last executed command
trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG #trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG
# Echo an error message before exiting ## Echo an error message before exiting
trap 'echo "\"${last_command}\" command exited with code $?."' EXIT #trap 'echo "\"${last_command}\" command exited with code $?."' EXIT
# Remove temporary file # Remove temporary file
trap 'rm -f $TMPFILE' EXIT trap 'rm -f $TMPFILE' EXIT
source /etc/birdnet/birdnet.conf source /etc/birdnet/birdnet.conf
[ -z ${RECORDING_LENGTH} ] && RECORDING_LENGTH=12
# Set Variables # Set Variables
TMPFILE=$(mktemp) TMPFILE=$(mktemp)
@@ -73,7 +74,7 @@ for h in "${SCAN_DIRS[@]}";do
START="$(echo "${line}" | awk -F\; '!/birdnet/{print $1}')" START="$(echo "${line}" | awk -F\; '!/birdnet/{print $1}')"
END="$(echo "${line}" | awk -F\; '!/birdnet/{print $2}')" END="$(echo "${line}" | awk -F\; '!/birdnet/{print $2}')"
COMMON_NAME=""$(echo ${line} \ COMMON_NAME=""$(echo ${line} \
| awk -F\; '!/birdnet/{print $4}')"" | awk -F\; '!/birdnet/{print $4}'|tr -d "'")""
SCIENTIFIC_NAME=""$(echo ${line} \ SCIENTIFIC_NAME=""$(echo ${line} \
| awk -F\; '!/birdnet/{print $3}')"" | awk -F\; '!/birdnet/{print $3}')""
CONFIDENCE=""$(echo ${line} \ CONFIDENCE=""$(echo ${line} \
@@ -115,10 +116,10 @@ for h in "${SCAN_DIRS[@]}";do
# If there are already 20 extracted entries for a given species # If there are already 20 extracted entries for a given species
# for today, remove the oldest file and create the new one. # for today, remove the oldest file and create the new one.
# if [[ "$(find ${NEWSPECIES_BYDATE} | wc -l)" -ge 21 ]];then # if [[ "$(find ${NEWSPECIES_BYDATE} | wc -l)" -ge 20 ]];then
# echo "20 ${SPECIES}s, already! Removing the oldest by-date and making a new one" # echo "20 ${SPECIES}s, already! Removing the oldest by-date and making a new one"
# cd ${NEWSPECIES_BYDATE} || exit 1 # cd ${NEWSPECIES_BYDATE} || exit 1
# ls -1t . | tail -n +21 | xargs -r rm -vv # ls -1t . | tail -n +20 | xargs -r rm -vv
# fi # fi
echo "Extracting audio . . . " echo "Extracting audio . . . "
@@ -127,34 +128,48 @@ for h in "${SCAN_DIRS[@]}";do
# structured by-species, symbolic links are made to populate the new # structured by-species, symbolic links are made to populate the new
# directory. # directory.
### TESTING longer extraction context # This section sets the SPACER that will be used to pad the audio clip with
# context. If EXTRACTION_LENGTH is 10, for instance, 3 seconds are removed
# from that value and divided by 2, so that the 3 seconds of the call are
# within 3.5 seconds of audio context before and after.
[ -z ${EXTRACTION_LENGTH} ] && EXTRACTION_LENGTH=6 [ -z ${EXTRACTION_LENGTH} ] && EXTRACTION_LENGTH=6
SPACER=$(echo "scale=1;(${EXTRACTION_LENGTH} - 3 )/2" |bc -l) SPACER=$(echo "scale=1;(${EXTRACTION_LENGTH} - 3 )/2" |bc -l)
START=$(echo "scale=1;${START} - ${SPACER}"|bc -l) START=$(echo "scale=1;${START} - ${SPACER}"|bc -l)
END=$(echo "scale=1;${END} + ${SPACER}"|bc -l) END=$(echo "scale=1;${END} + ${SPACER}"|bc -l)
if (( $(echo "scale=1;${START} < 1" | bc -l) ));then START=0;fi # If the SPACER would have the START value less that 0, start at the
if (( $(echo "scale=1;${END} > ${RECORDING_LENGTH}" | bc -l) ));then END=${RECORDING_LENGTH};fi # beginning of the audio file. If the SPACER would make the END value
# exceed the end of the audio file, end the extraction at the end of the
# audio file.
if (( $(echo "${START} < 1" | bc -l) ));then START=0;fi
if (( $(echo "${END} > ${RECORDING_LENGTH}" | bc -l) ));then END=${RECORDING_LENGTH};fi
ffmpeg -hide_banner -loglevel error -nostdin -i "${h}/${OLDFILE}" \ ffmpeg -hide_banner -loglevel error -nostdin -i "${h}/${OLDFILE}" \
-acodec copy -ss "${START}" -to "${END}"\ -acodec copy -ss "${START}" -to "${END}"\
"${NEWSPECIES_BYDATE}/${a}-${NEWFILE}" "${NEWSPECIES_BYDATE}/${a}-${NEWFILE}"
if [[ "$(find ${NEWSPECIES_BY_COMMON} | wc -l)" -ge 21 ]];then
# Remove the oldest symbolic links that would made the directory have more
# than 20 entries.
if [[ "$(find ${NEWSPECIES_BY_COMMON} | wc -l)" -ge 20 ]];then
echo "20 ${SPECIES}s, already! Removing the oldest by-species and making a new one" echo "20 ${SPECIES}s, already! Removing the oldest by-species and making a new one"
cd ${NEWSPECIES_BY_COMMON} || exit 1 cd ${NEWSPECIES_BY_COMMON} || exit 1
ls -1t . | tail -n +21 | xargs -r rm -vv ls -1t . | tail -n +20 | xargs -r rm -vv
ln -fs "${NEWSPECIES_BYDATE}/${a}-${NEWFILE}"\ ln -fs "${NEWSPECIES_BYDATE}/${a}-${NEWFILE}"\
"${NEWSPECIES_BY_COMMON}/${a}-${NEWFILE}" "${NEWSPECIES_BY_COMMON}/${a}-${NEWFILE}"
echo "Success! New extraction for ${COMMON_NAME}" echo "Success! New extraction for ${COMMON_NAME}"
else else
# Make symbolic link of the extraction to add to By_Common_Name
ln -fs "${NEWSPECIES_BYDATE}/${a}-${NEWFILE}"\ ln -fs "${NEWSPECIES_BYDATE}/${a}-${NEWFILE}"\
"${NEWSPECIES_BY_COMMON}/${a}-${NEWFILE}" "${NEWSPECIES_BY_COMMON}/${a}-${NEWFILE}"
fi fi
if [[ "$(find ${NEWSPECIES_BY_SCIENCE} | wc -l)" -ge 21 ]];then # Remove the oldest symbolic links that would made the directory have more
# than 20 entries.
if [[ "$(find ${NEWSPECIES_BY_SCIENCE} | wc -l)" -ge 20 ]];then
echo "20 ${SPECIES}s, already! Removing the oldest by-species and making a new one" echo "20 ${SPECIES}s, already! Removing the oldest by-species and making a new one"
cd ${NEWSPECIES_BY_SCIENCE} || exit 1 cd ${NEWSPECIES_BY_SCIENCE} || exit 1
ls -1t . | tail -n +21 | xargs -r rm -vv ls -1t . | tail -n +20 | xargs -r rm -vv
ln -fs "${NEWSPECIES_BYDATE}/${a}-${NEWFILE}"\ ln -fs "${NEWSPECIES_BYDATE}/${a}-${NEWFILE}"\
"${NEWSPECIES_BY_SCIENCE}/${a}-${NEWFILE}" "${NEWSPECIES_BY_SCIENCE}/${a}-${NEWFILE}"
echo "Success! New extraction for ${COMMON_NAME}" echo "Success! New extraction for ${COMMON_NAME}"
+8 -1
View File
@@ -1,3 +1,7 @@
<form action="/scripts/edit_birdnet.conf.php">
<input type="submit" value="Edit the birdnet.conf file">
</form>
<form action="/scripts/restart_services.php"> <form action="/scripts/restart_services.php">
<input type="submit" value="Restart ALL BirdNET-system Services"> <input type="submit" value="Restart ALL BirdNET-system Services">
</form> </form>
@@ -18,6 +22,10 @@
<input type="submit" value="Restart Caddy"> <input type="submit" value="Restart Caddy">
</form> </form>
<form action="/scripts/clear_all_data.php">
<input type="submit" value="Clear ALL data">
</form>
<form action="/scripts/reboot_system.php"> <form action="/scripts/reboot_system.php">
<input type="submit" value="Reboot BirdNET-system"> <input type="submit" value="Reboot BirdNET-system">
</form> </form>
@@ -25,4 +33,3 @@
<form action="/scripts/shutdown_system.php"> <form action="/scripts/shutdown_system.php">
<input type="submit" value="Shutdown BirdNET-system"> <input type="submit" value="Shutdown BirdNET-system">
</form> </form>
-2
View File
@@ -46,7 +46,6 @@ install_deps() {
} }
install_birdnet() { install_birdnet() {
set -xe
cd ~/BirdNET-Lite || exit 1 cd ~/BirdNET-Lite || exit 1
echo "Upgrading pip, wheel, and setuptools" echo "Upgrading pip, wheel, and setuptools"
sudo pip3 install --upgrade pip wheel setuptools sudo pip3 install --upgrade pip wheel setuptools
@@ -62,7 +61,6 @@ install_birdnet() {
sudo pip3 install colorama==0.4.4 sudo pip3 install colorama==0.4.4
echo "Installing librosa" echo "Installing librosa"
sudo pip3 install librosa sudo pip3 install librosa
set +x
} }
read -sp "\ read -sp "\
+53 -1
View File
@@ -79,6 +79,7 @@ create_necessary_dirs() {
[ -d ${EXTRACTED}/By_Scientific_Name ] || sudo -u ${USER} mkdir -p ${EXTRACTED}/By_Scientific_Name [ -d ${EXTRACTED}/By_Scientific_Name ] || sudo -u ${USER} mkdir -p ${EXTRACTED}/By_Scientific_Name
[ -d ${PROCESSED} ] || sudo -u ${USER} mkdir -p ${PROCESSED} [ -d ${PROCESSED} ] || sudo -u ${USER} mkdir -p ${PROCESSED}
[ -L ${EXTRACTED}/scripts ] || sudo -u ${USER} ln -s $(dirname ${my_dir})/scripts ${EXTRACTED} [ -L ${EXTRACTED}/scripts ] || sudo -u ${USER} ln -s $(dirname ${my_dir})/scripts ${EXTRACTED}
[ -L ${EXTRACTED}/spectrogram.php ] || sudo -u ${USER} ln -s $(dirname ${my_dir})/scripts/spectrogram.* ${EXTRACTED}
} }
install_alsa() { install_alsa() {
@@ -196,6 +197,9 @@ ${EXTRACTIONS_URL} {
basicauth /Processed* { basicauth /Processed* {
birdnet ${HASHWORD} birdnet ${HASHWORD}
} }
basicauth /scripts* {
birdnet ${HASHWORD}
}
basicauth /stream { basicauth /stream {
birdnet ${HASHWORD} birdnet ${HASHWORD}
} }
@@ -209,6 +213,9 @@ http://birdnetsystem.local {
basicauth /Processed* { basicauth /Processed* {
birdnet ${HASHWORD} birdnet ${HASHWORD}
} }
basicauth /scripts* {
birdnet ${HASHWORD}
}
basicauth /stream { basicauth /stream {
birdnet ${HASHWORD} birdnet ${HASHWORD}
} }
@@ -311,7 +318,7 @@ RestartSec=3
Type=simple Type=simple
User=${USER} User=${USER}
Environment=TERM=xterm-256color Environment=TERM=xterm-256color
ExecStart=/usr/local/bin/gotty -p 9090 --title-format "BirdNET-Lite Statistics" /usr/local/bin/birdnet_stats.sh ExecStart=/usr/local/bin/gotty -p 9090 --title-format "BirdNET-Lite Statistics" tmux new -A -s birdstats /usr/local/bin/birdnet_stats.sh
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
@@ -319,6 +326,29 @@ EOF
systemctl enable --now birdstats.service systemctl enable --now birdstats.service
} }
install_tmux() {
echo "Installing tmux dependencies"
apt -qqy install libevent-2* \
libevent-dev \
ncurses-bin \
ncurses-base \
ncurses-term \
libncurses-dev
cp $(dirname ${my_dir})/templates/tmux.conf /etc/tmux.conf
}
install_sox() {
if which sox &> /dev/null;then
echo "Sox is installed"
else
echo "Installing sox"
apt -qq update
apt install -y sox
echo "Sox installed"
fi
}
install_php() { install_php() {
if ! which pip &> /dev/null || ! which php-fpm7.3;then if ! which pip &> /dev/null || ! which php-fpm7.3;then
echo "Installing PHP and PHP-FPM" echo "Installing PHP and PHP-FPM"
@@ -337,6 +367,25 @@ EOF
chmod 0440 /etc/sudoers.d/010_caddy-nopasswd chmod 0440 /etc/sudoers.d/010_caddy-nopasswd
} }
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" tmux new -A -s editbirdnet nano /home/pi/BirdNET-Lite/birdnet.conf
[Install]
WantedBy=multi-user.target
EOF
}
install_icecast() { install_icecast() {
if ! which icecast2;then if ! which icecast2;then
echo "Installing IceCast2" echo "Installing IceCast2"
@@ -443,7 +492,10 @@ install_selected_services() {
install_Caddyfile install_Caddyfile
install_avahi_aliases install_avahi_aliases
install_gotty_logs install_gotty_logs
install_tmux
install_sox
install_php install_php
install_edit_birdnet_conf
fi fi
if [ ! -z "${ICE_PWD}" ];then if [ ! -z "${ICE_PWD}" ];then
+4
View File
@@ -0,0 +1,4 @@
<?php
shell_exec("/home/pi/BirdSongs/Extracted/spectrogram.sh");
header('Location: http://birdnetsystem.local/spectrogram.png');
?>
+6
View File
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
# Make sox spectrogram
source /etc/birdnet/birdnet.conf
analyzing_now="$(cat /home/pi/BirdNET-Lite/analyzing_now.txt)"
spectrogram_png=${EXTRACTED}/spectrogram.png
sudo -u pi sox "${analyzing_now}" -n spectrogram -o "${spectrogram_png}"
Executable
BIN
View File
Binary file not shown.
+9 -2
View File
@@ -7,9 +7,12 @@ SCRIPTS=(birdnet_analysis.sh
birdnet_recording.sh birdnet_recording.sh
birdnet_stats.sh birdnet_stats.sh
cleanup.sh cleanup.sh
clear_all_data.php
clear_all_data.sh clear_all_data.sh
disk_usage.sh disk_usage.sh
dump_logs.sh dump_logs.sh
edit_birdnet.conf.php
edit_birdnet.conf.sh
extract_new_birdsounds.sh extract_new_birdsounds.sh
install_birdnet.sh install_birdnet.sh
install_config.sh install_config.sh
@@ -31,7 +34,10 @@ restart_extraction.php
restart_extraction.sh restart_extraction.sh
restart_services.php restart_services.php
restart_services.sh restart_services.sh
shutdown_system.php
shutdown_system.sh
species_notifier.sh species_notifier.sh
tmux
uninstall.sh uninstall.sh
update_species.sh update_species.sh
${HOME}/.gotty) ${HOME}/.gotty)
@@ -51,6 +57,7 @@ birdstats.service
birdterminal.service birdterminal.service
caddy.d caddy.d
caddy.service caddy.service
edit_birdnet_conf.service
extraction_log.service extraction_log.service
extraction.d extraction.d
extraction.service extraction.service
@@ -89,8 +96,8 @@ remove_icecast() {
remove_scripts() { remove_scripts() {
for i in "${SCRIPTS[@]}";do for i in "${SCRIPTS[@]}";do
if [ -L "${i}" ];then if [ -L "/usr/local/bin/${i}" ];then
sudo rm -v "${i}" sudo rm -v "/usr/local/bin/${i}"
fi fi
done done
} }
+11 -1
View File
@@ -66,6 +66,16 @@ h2 {
color: #999; color: #999;
} }
h2 {
padding-left: 5%;
font-size: 16px;
font-weight: normal;
white-space: nowrap;
overflow-x: hidden;
text-overflow: ellipsis;
color: #999;
}
h1 a { h1 a {
color: #000; color: #000;
margin: 0 4px; margin: 0 4px;
@@ -487,4 +497,4 @@ footer {
timeList.forEach(localizeDatetime); timeList.forEach(localizeDatetime);
</script> </script>
</body> </body>
</html> </html>
+2
View File
@@ -0,0 +1,2 @@
rpialpha
Thu 07 Oct 2021 04:09:31 PM EDT