From 73417ee3afdfbc82833e414601cb2be9f97db723 Mon Sep 17 00:00:00 2001 From: Patrick McGuire Date: Wed, 20 Oct 2021 18:47:00 -0400 Subject: [PATCH] adding new homepage for testing :) - replaced all SERVICES arrays with commands - altered {install,update}_services.sh to install new homepage - renamed old index.html to mobile.html for mobile redirect --- Testing_UPDATER | 1 - homepage/external.html | 60 ++++++++++++++++ homepage/footer.html | 28 ++++++++ homepage/index.html | 37 ++++++++++ homepage/menu.html | 28 ++++++++ templates/index.html => homepage/mobile.html | 0 homepage/top.html | 36 ++++++++++ scripts/dump_logs.sh | 17 +---- scripts/install_services.sh | 11 ++- scripts/install_tmux_services.sh | 76 -------------------- scripts/restart_services.sh | 13 +--- scripts/uninstall.sh | 24 +------ scripts/update_services.sh | 9 ++- scripts/viewdb.php | 9 +-- 14 files changed, 210 insertions(+), 139 deletions(-) delete mode 100644 Testing_UPDATER create mode 100644 homepage/external.html create mode 100644 homepage/footer.html create mode 100644 homepage/index.html create mode 100644 homepage/menu.html rename templates/index.html => homepage/mobile.html (100%) create mode 100644 homepage/top.html delete mode 100755 scripts/install_tmux_services.sh diff --git a/Testing_UPDATER b/Testing_UPDATER deleted file mode 100644 index 1f7ec48..0000000 --- a/Testing_UPDATER +++ /dev/null @@ -1 +0,0 @@ -I hope this works:) diff --git a/homepage/external.html b/homepage/external.html new file mode 100644 index 0000000..ec8343d --- /dev/null +++ b/homepage/external.html @@ -0,0 +1,60 @@ + + +HTML Frames Example - Content + + + +tbc.... +

Thanks

+stefan kahl +patrick mcguire +

Similar Systems

+

Technical Details

+machine learning +deep learning +

Used Tools

+SoX +ffmpeg +Python +Tensorfflow (Lite) +Rasberian OS +

Disclaimer

+

Other Systems

+links to other systems + + + +

Content

+

Replacing the Contents of the Current Frame

+

Clicking on these links will open the new page within the current frame.

+ + +

Replacing the Whole Frameset

+

When you click on any of the following links, the whole frameset is replaced with the new website. This is because we're using target="_top" in the anchor links.

+ + +

Open a New Window

+

These links open in a new browser window. This is because we use target="_blank".

+ + + + \ No newline at end of file diff --git a/homepage/footer.html b/homepage/footer.html new file mode 100644 index 0000000..0afb85b --- /dev/null +++ b/homepage/footer.html @@ -0,0 +1,28 @@ + + +HTML Frames Example - Footer + + + +

External Services

+

Project Page | + Wiki Help Page | + Live Audio Stream | + Realtime Spectrogram | + Links to External Pages | + Weather | + The Cornell Lab of Ornitology +

+ + diff --git a/homepage/index.html b/homepage/index.html new file mode 100644 index 0000000..5c6892a --- /dev/null +++ b/homepage/index.html @@ -0,0 +1,37 @@ + + + + +BirdNET-Pi + + + + + + + + + + + + + + +<p>This section (everything between the 'noframes' tags) will only be displayed if the users' browser doesn't support frames. You can provide a link to a non-frames version of the website here. Feel free to use HTML tags within this section.</p> + + + + diff --git a/homepage/menu.html b/homepage/menu.html new file mode 100644 index 0000000..52de33d --- /dev/null +++ b/homepage/menu.html @@ -0,0 +1,28 @@ + + +HTML Frames Example - Menu + + + +

Extractions

+By Common Name
+By Date
+By Scientiffic Name
+Processed
+

GitHub

+Repository
+Discussions
+Issues
+ + diff --git a/templates/index.html b/homepage/mobile.html similarity index 100% rename from templates/index.html rename to homepage/mobile.html diff --git a/homepage/top.html b/homepage/top.html new file mode 100644 index 0000000..5f9eaae --- /dev/null +++ b/homepage/top.html @@ -0,0 +1,36 @@ + + + BirdNET-Pi + + + +
+ +
+

BirdNET-Pi

+

+ Recognized Birds Library | + Deep Learning Analysis | + Audio Extraction | + Hardware | + System +

+ + diff --git a/scripts/dump_logs.sh b/scripts/dump_logs.sh index 101e967..bc11c8b 100755 --- a/scripts/dump_logs.sh +++ b/scripts/dump_logs.sh @@ -3,25 +3,14 @@ # set -x # Uncomment to debug source /etc/birdnet/birdnet.conf &> /dev/null LOG_DIR="${HOME}/BirdNET-Pi/logs" -SERVICES=(avahi-alias@.service -birdnet_analysis.service -birdnet_log.service -birdnet_recording.service -birdstats.service -birdterminal.service -caddy.service -extraction_log.service -extraction.service -extraction.timer -icecast2.service -livestream.service -${SYSTEMD_MOUNT}) + +services=$(awk '/service/ && /systemctl/ && !/php/ {print $3}' ${my_dir}/install_services.sh | sort) # Create logs directory [ -d ${LOG_DIR} ] || mkdir ${LOG_DIR} # Create services logs -for i in "${SERVICES[@]}";do +for i in "${services[@]}";do if [ -L /etc/systemd/system/multi-user.target.wants/${i} ];then journalctl -u ${i} -n 100 --no-pager > ${LOG_DIR}/${i}.log cp -L /etc/systemd/system/multi-user.target.wants/${i} ${LOG_DIR}/${i} diff --git a/scripts/install_services.sh b/scripts/install_services.sh index 7dab9c0..ffa8303 100755 --- a/scripts/install_services.sh +++ b/scripts/install_services.sh @@ -109,17 +109,17 @@ create_necessary_dirs() { [ -d ${EXTRACTED}/By_Scientific_Name ] || sudo -u ${USER} mkdir -p ${EXTRACTED}/By_Scientific_Name [ -d ${PROCESSED} ] || sudo -u ${USER} mkdir -p ${PROCESSED} - sudo -u ${USER} ln -fs $(dirname ${my_dir})/templates/index.html ${EXTRACTED} + sudo -u ${USER} ln -fs $(dirname ${my_dir})/homepage/* ${EXTRACTED} if [ ! -z ${BIRDNETLOG_URL} ];then BIRDNETLOG_URL="$(echo ${BIRDNETLOG_URL} | sed 's/\/\//\\\/\\\//g')" - sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local:8080/"${BIRDNETLOG_URL}"/g" $(dirname ${my_dir})/templates/index.html + sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local:8080/"${BIRDNETLOG_URL}"/g" $(dirname ${my_dir})/homepage/* fi if [ ! -z ${EXTRACTIONLOG_URL} ];then EXTRACTIONLOG_URL="$(echo ${EXTRACTIONLOG_URL} | sed 's/\/\//\\\/\\\//g')" - sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local:8888/"${EXTRACTIONLOG_URL}"/g" $(dirname ${my_dir})/templates/index.html + sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local:8888/"${EXTRACTIONLOG_URL}"/g" $(dirname ${my_dir})/homepage/* fi - [ -L ${EXTRACTED}/scripts ] || sudo -u ${USER} ln -s $(dirname ${my_dir})/scripts ${EXTRACTED} + sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts ${EXTRACTED} if [ ! -z ${BIRDNETPI_URL} ];then BIRDNETPI_URL="$(echo ${BIRDNETPI_URL} | sed 's/\/\//\\\/\\\//g')" phpfiles="$(grep -l birdnetpi.local ${my_dir}/*.php)" @@ -132,9 +132,8 @@ create_necessary_dirs() { sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/viewdb.php ${EXTRACTED} sudo -u ${USER} ln -fs ${HOME}/phpsysinfo ${EXTRACTED} [ -L ${EXTRACTED}/phpsysinfo/phpsysinfo.ini ] || sudo -u ${USER} cp ${HOME}/phpsysinfo/phpsysinfo.ini.new ${HOME}/phpsysinfo/phpsysinfo.ini - } - + install_alsa() { echo "Checking for alsa-utils and pulseaudio" if which arecord &> /dev/null ;then diff --git a/scripts/install_tmux_services.sh b/scripts/install_tmux_services.sh deleted file mode 100755 index 49512af..0000000 --- a/scripts/install_tmux_services.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env bash -# This script installs a web-based terminal @ http://birdterminal.local -# ONLY run this additional script if you trust everyone on your -# local network completely as the credentials are sent WITHOUT -# any SSL/TLS encryption. For a secure remote connection to your -# BirdNET-Pi command line, consider enabling SSH on the -# Raspberry Pi and using another Linux machine or an SSH -# client software, or you can alternately add the 'tls internal' -# directive to the Caddyfile to add a self-signed certificate for TLS/SSL -# encryption. For remote desktop access, NoMachine can be installed. -source /etc/birdnet/birdnet.conf -my_dir=$(realpath $(dirname $0)) - -# Install tmux from version control -install_tmux() { - DEPENDS=( - automake - autoconf - libevent-2* - libevent-dev - ncurses-bin - ncurses-base - ncurses-term - libncurses-dev - build-essential - bison - pkg-config - gcc - ) - - if which tmux &>/dev/null; then - echo "tmux is installed" - else - - sudo apt update && sudo apt -y install "${DEPENDS[@]}" - - cd ${HOME} && git clone https://github.com/tmux/tmux.git - cd tmux - sh autogen.sh - ./configure && make && sudo make install - cd && rm -drf ./tmux - sudo ln -sf "$(dirname ${my_dir})/templates/tmux.conf" /etc/tmux.conf - fi -} - -install_web_terminal() { - cat << EOF | sudo tee /etc/systemd/system/birdterminal.service -[Unit] -Description=A BirdNET-Pi Web Terminal - -[Service] -Restart=on-failure -RestartSec=3 -Type=simple -User=${BIRDNET_USER} -Environment=TERM=xterm-256color -ExecStart=/usr/local/bin/gotty -w --title-format "Login!" -p 9111 tmux new -A -s Login sudo bash -c login - -[Install] -WantedBy=multi-user.target -EOF - HASHWORD="$(caddy hash-password -plaintext "${CADDY_PWD}")" - cat << EOF | sudo tee -a /etc/caddy/Caddyfile -http://birdterminal.local { - reverse_proxy localhost:9111 - basicauth { - birdnet "${HASHWORD}" - } -} -EOF - sudo systemctl enable --now birdterminal.service - sudo systemctl enable --now avahi-alias@birdterminal.local.service - sudo systemctl restart caddy -} -install_tmux -install_web_terminal diff --git a/scripts/restart_services.sh b/scripts/restart_services.sh index f767776..1cc4367 100755 --- a/scripts/restart_services.sh +++ b/scripts/restart_services.sh @@ -6,18 +6,9 @@ sudo systemctl stop birdnet_recording.service sudo rm -rf ${RECS_DIR}/$(date +%B-%Y/%d-%A)/* sudo systemctl start birdnet_recording.service -SERVICES=(avahi-alias@birdlog.local.service -avahi-alias@birdnetpi.local.service -avahi-alias@birdstats.local.service -avahi-alias@extractionlog.local.service -birdnet_analysis.service -birdnet_log.service -birdstats.service -extraction.timer -extractionlog.service -livestream.service) +services=$(awk '/service/ && /systemctl/ && !/php/ {print $3}' ${my_dir}/install_services.sh | sort) -for i in "${SERVICES[@]}";do +for i in "${services[@]}";do sudo systemctl restart ${i} done diff --git a/scripts/uninstall.sh b/scripts/uninstall.sh index ed8fc6c..9cd8ce5 100755 --- a/scripts/uninstall.sh +++ b/scripts/uninstall.sh @@ -45,30 +45,10 @@ uninstall.sh update_species.sh ${HOME}/.gotty) - -SERVICES=(avahi-alias@birdlog.local.service -avahi-alias@birdnetpi.local.service -avahi-alias@birdstats.local.service -avahi-alias@extractionlog.local.service -avahi-alias@birdterminal.local.service -birdnet_analysis.service -birdnet_log.service -birdnet_recording.d -birdnet_recording.service -birdstats.service -birdterminal.service -caddy.service -edit_birdnet_conf.service -extraction_log.service -extraction.service -extraction.timer -livestream.service -pushed_notifications.service -spectrogram_viewer.service -${SYSTEMD_MOUNT}) +services=$(awk '/service/ && /systemctl/ && !/php/ {print $3}' ${my_dir}/install_services.sh | sort) remove_services() { - for i in "${SERVICES[@]}"; do + for i in "${services[@]}"; do if [ -L /etc/systemd/system/multi-user.target.wants/"${i}" ];then sudo systemctl disable --now "${i}" fi diff --git a/scripts/update_services.sh b/scripts/update_services.sh index 708334a..9ebbb43 100755 --- a/scripts/update_services.sh +++ b/scripts/update_services.sh @@ -109,14 +109,14 @@ create_necessary_dirs() { [ -d ${EXTRACTED}/By_Scientific_Name ] || sudo -u ${USER} mkdir -p ${EXTRACTED}/By_Scientific_Name [ -d ${PROCESSED} ] || sudo -u ${USER} mkdir -p ${PROCESSED} - sudo -u ${USER} ln -fs $(dirname ${my_dir})/templates/index.html ${EXTRACTED} + sudo -u ${USER} ln -fs $(dirname ${my_dir})/homepage/* ${EXTRACTED} if [ ! -z ${BIRDNETLOG_URL} ];then BIRDNETLOG_URL="$(echo ${BIRDNETLOG_URL} | sed 's/\/\//\\\/\\\//g')" - sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local:8080/"${BIRDNETLOG_URL}"/g" $(dirname ${my_dir})/templates/index.html + sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local:8080/"${BIRDNETLOG_URL}"/g" $(dirname ${my_dir})/homepage/* fi if [ ! -z ${EXTRACTIONLOG_URL} ];then EXTRACTIONLOG_URL="$(echo ${EXTRACTIONLOG_URL} | sed 's/\/\//\\\/\\\//g')" - sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local:8888/"${EXTRACTIONLOG_URL}"/g" $(dirname ${my_dir})/templates/index.html + sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local:8888/"${EXTRACTIONLOG_URL}"/g" $(dirname ${my_dir})/homepage/* fi sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts ${EXTRACTED} @@ -128,13 +128,12 @@ create_necessary_dirs() { done fi - sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/spectrogram.* ${EXTRACTED} sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/viewdb.php ${EXTRACTED} sudo -u ${USER} ln -fs ${HOME}/phpsysinfo ${EXTRACTED} [ -L ${EXTRACTED}/phpsysinfo/phpsysinfo.ini ] || sudo -u ${USER} cp ${HOME}/phpsysinfo/phpsysinfo.ini.new ${HOME}/phpsysinfo/phpsysinfo.ini } - + install_alsa() { echo "Checking for alsa-utils and pulseaudio" if which arecord &> /dev/null ;then diff --git a/scripts/viewdb.php b/scripts/viewdb.php index 41075cf..9b55c4c 100644 --- a/scripts/viewdb.php +++ b/scripts/viewdb.php @@ -59,18 +59,17 @@ $mysqli->close(); - + BirdNET-Pi DB - + +

Number of Detections