Merge pull request #15 from mcguirepr89/rpialpha

Rpialpha
This commit is contained in:
mcguirepr89
2021-10-08 11:52:05 -04:00
committed by GitHub
16 changed files with 282 additions and 125 deletions
+7 -2
View File
@@ -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>
+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
} }
+60 -44
View File
@@ -54,6 +54,16 @@ h1 {
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;
@@ -128,12 +138,13 @@ td {
} }
td:nth-child(2) { td:nth-child(2) {
width: 80%; width: 100%;
} }
td:nth-child(3), td:nth-child(3),
th:nth-child(3) { th:nth-child(3) {
padding: 0 20px 0 20px; #padding: 0 20px 0 20px;
width: 0px;
} }
th:nth-child(4), th:nth-child(4),
@@ -269,9 +280,9 @@ footer {
<path d="M285.22 37.55h-142.6L110.9 0H31.7C14.25 0 0 16.9 0 37.55v75.1h316.92V75.1c0-20.65-14.26-37.55-31.7-37.55z" fill="#FFA000"/> <path d="M285.22 37.55h-142.6L110.9 0H31.7C14.25 0 0 16.9 0 37.55v75.1h316.92V75.1c0-20.65-14.26-37.55-31.7-37.55z" fill="#FFA000"/>
<path d="M285.22 36H31.7C14.25 36 0 50.28 0 67.74v158.7c0 17.47 14.26 31.75 31.7 31.75H285.2c17.44 0 31.7-14.3 31.7-31.75V67.75c0-17.47-14.26-31.75-31.7-31.75z" fill="#FFCA28"/> <path d="M285.22 36H31.7C14.25 36 0 50.28 0 67.74v158.7c0 17.47 14.26 31.75 31.7 31.75H285.2c17.44 0 31.7-14.3 31.7-31.75V67.75c0-17.47-14.26-31.75-31.7-31.75z" fill="#FFCA28"/>
</g> </g>
<g id="folder-shortcut" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"> <g id="folder" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="folder-shortcut-group" fill-rule="nonzero"> <g id="folder-group" fill-rule="nonzero">
<g id="folder-shortcut-shape"> <g id="folder-shape">
<path d="M285.224876,37.5486902 L142.612438,37.5486902 L110.920785,0 L31.6916529,0 C14.2612438,0 0,16.8969106 0,37.5486902 L0,112.646071 L316.916529,112.646071 L316.916529,75.0973805 C316.916529,54.4456008 302.655285,37.5486902 285.224876,37.5486902 Z" id="Shape" fill="#FFA000"></path> <path d="M285.224876,37.5486902 L142.612438,37.5486902 L110.920785,0 L31.6916529,0 C14.2612438,0 0,16.8969106 0,37.5486902 L0,112.646071 L316.916529,112.646071 L316.916529,75.0973805 C316.916529,54.4456008 302.655285,37.5486902 285.224876,37.5486902 Z" id="Shape" fill="#FFA000"></path>
<path d="M285.224876,36 L31.6916529,36 C14.2612438,36 0,50.2838568 0,67.7419039 L0,226.451424 C0,243.909471 14.2612438,258.193328 31.6916529,258.193328 L285.224876,258.193328 C302.655285,258.193328 316.916529,243.909471 316.916529,226.451424 L316.916529,67.7419039 C316.916529,50.2838568 302.655285,36 285.224876,36 Z" id="Shape" fill="#FFCA28"></path> <path d="M285.224876,36 L31.6916529,36 C14.2612438,36 0,50.2838568 0,67.7419039 L0,226.451424 C0,243.909471 14.2612438,258.193328 31.6916529,258.193328 L285.224876,258.193328 C302.655285,258.193328 316.916529,243.909471 316.916529,226.451424 L316.916529,67.7419039 C316.916529,50.2838568 302.655285,36 285.224876,36 Z" id="Shape" fill="#FFCA28"></path>
</g> </g>
@@ -311,30 +322,25 @@ footer {
<a href="">BirdNET-Lite System</a> <a href="">BirdNET-Lite System</a>
</h1> </h1>
</header> </header>
<h2>
<a href="./stream">
<span class="name">Live Audio Stream</span>
</a>
</h2>
<h2>
<a href="http://birdnetsystem.local:9090">
<span class="name">BirdNET-system Report</span>
</a>
</h2>
<main> <main>
<div class="meta">
<div id="summary">
<span class="meta-item"><b>5</b> directories</span>
<span class="meta-item"><b>1</b> file</span>
<span class="meta-item"><input type="text" placeholder="filter" id="filter" onkeyup='filter()'></span>
</div>
</div>
<div class="listing"> <div class="listing">
<table aria-describedby="summary"> <table aria-describedby="summary">
<thead> <thead>
<tr> <tr>
<th></th> <th></th>
<th> <th>
<a href="?sort=namedirfirst&order=desc" class="icon"><svg width="1em" height=".5em" version="1.1" viewBox="0 0 12.922194 6.0358899"><use xlink:href="#up-arrow"></use></svg></a> <a href="?sort=name&order=asc">Extractions</a>
<a href="?sort=name&order=asc">Name</a>
</th> </th>
<th>
<a href="?sort=size&order=asc">Size</a>
</th>
<th class="hideable">
<a href="?sort=time&order=asc">Modified</a>
</th>
<th class="hideable"></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -346,9 +352,6 @@ footer {
<span class="name">By_Common_Name</span> <span class="name">By_Common_Name</span>
</a> </a>
</td> </td>
<td data-order="-1">&mdash;</td>
<td class="hideable"><time datetime="2021-10-03T23:13:48Z">10/03/2021 11:13:48 PM +00:00</time></td>
<td class="hideable"></td>
</tr> </tr>
<tr class="file"> <tr class="file">
<td></td> <td></td>
@@ -358,9 +361,6 @@ footer {
<span class="name">By_Date</span> <span class="name">By_Date</span>
</a> </a>
</td> </td>
<td data-order="-1">&mdash;</td>
<td class="hideable"><time datetime="2021-10-03T23:13:48Z">10/03/2021 11:13:48 PM +00:00</time></td>
<td class="hideable"></td>
</tr> </tr>
<tr class="file"> <tr class="file">
<td></td> <td></td>
@@ -370,45 +370,61 @@ footer {
<span class="name">By_Scientific_Name</span> <span class="name">By_Scientific_Name</span>
</a> </a>
</td> </td>
<td data-order="-1">&mdash;</td>
<td class="hideable"><time datetime="2021-10-03T23:13:48Z">10/03/2021 11:13:48 PM +00:00</time></td>
<td class="hideable"></td>
</tr> </tr>
<tr class="file"> <tr class="file">
<td></td> <td></td>
<td> <td>
<a href="./Processed/"> <a href="./Processed/">
<svg width="1.5em" height="1em" version="1.1" viewBox="0 0 317 259"><use xlink:href="#folder-shortcut"></use></svg> <svg width="1.5em" height="1em" version="1.1" viewBox="0 0 317 259"><use xlink:href="#folder"></use></svg>
<span class="name">Processed</span> <span class="name">Processed</span>
</a> </a>
</td> </td>
<td data-order="-1">&mdash;</td>
<td class="hideable"><time datetime="2021-10-03T23:23:16Z">10/03/2021 11:23:16 PM +00:00</time></td>
<td class="hideable"></td>
</tr> </tr>
</tbody>
<thead>
<tr>
<th></th>
<th>
<a href="?sort=name&order=asc">Tools</a>
</th>
</tr>
</thead>
<tr class="file"> <tr class="file">
<td></td> <td></td>
<td> <td>
<a href="./scripts/"> <a href="./scripts/">
<svg width="1.5em" height="1em" version="1.1" viewBox="0 0 317 259"><use xlink:href="#folder-shortcut"></use></svg> <svg width="1.5em" height="1em" version="1.1" viewBox="0 0 317 259"><use xlink:href="#folder"></use></svg>
<span class="name">scripts</span> <span class="name">scripts</span>
</a> </a>
</td> </td>
<td data-order="-1">&mdash;</td>
<td class="hideable"><time datetime="2021-10-03T23:13:48Z">10/03/2021 11:13:48 PM +00:00</time></td>
<td class="hideable"></td>
</tr> </tr>
<tr class="file"> <tr class="file">
<td></td> <td></td>
<td> <td>
<a href="./stream"> <a href="http://birdnetsystem.local:8080">
<svg width="1.5em" height="1em" version="1.1" viewBox="0 0 265 323"><use xlink:href="#file"></use></svg> <svg width="1.5em" height="1em" version="1.1" viewBox="0 0 317 259"><use xlink:href="#folder"></use></svg>
<span class="name">stream</span> <span class="name">birdlog</span>
</a> </a>
</td> </td>
<td data-order="0">0 B</td> </tr>
<td class="hideable"><time datetime="2021-10-03T23:29:52Z">10/03/2021 11:29:52 PM +00:00</time></td> <tr class="file">
<td class="hideable"></td> <td></td>
<td>
<a href="http://birdnetsystem.local:8888">
<svg width="1.5em" height="1em" version="1.1" viewBox="0 0 317 259"><use xlink:href="#folder"></use></svg>
<span class="name">extractionlog</span>
</a>
</td>
</tr>
<tr class="file">
<td></td>
<td>
<form action="/spectrogram.php">
<input type="submit" value="Spectrogram View">
</form>
</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
+2
View File
@@ -0,0 +1,2 @@
rpialpha
Thu 07 Oct 2021 04:09:31 PM EDT