From ba92d7fd72e849e9b01b7d3cf1a63537bca771ba Mon Sep 17 00:00:00 2001 From: mcguirepr89 Date: Thu, 10 Feb 2022 09:34:43 -0500 Subject: [PATCH] less hard-coding links --- homepage/footer.html | 2 +- homepage/images/version.svg | 2 +- scripts/advanced.php | 288 +++++++++++++-------------- scripts/backup_data.php | 4 - scripts/backup_data.sh | 5 - scripts/restart_birdnet_analysis.php | 2 +- scripts/stop_core_services.php | 2 +- scripts/update_birdnet.php | 2 +- templates/Caddyfile_livestream | 17 -- templates/Caddyfile_nostream | 16 -- 10 files changed, 149 insertions(+), 191 deletions(-) delete mode 100644 scripts/backup_data.php delete mode 100755 scripts/backup_data.sh delete mode 100644 templates/Caddyfile_livestream delete mode 100644 templates/Caddyfile_nostream diff --git a/homepage/footer.html b/homepage/footer.html index da8e9f5..9741849 100644 --- a/homepage/footer.html +++ b/homepage/footer.html @@ -16,7 +16,7 @@ a { -

Play Live Audio

+

Play Live Audio

diff --git a/homepage/images/version.svg b/homepage/images/version.svg index 2f0d67a..ad898e3 100644 --- a/homepage/images/version.svg +++ b/homepage/images/version.svg @@ -1 +1 @@ -version: 0.11version0.11 +version: 0.11.1version0.11.1 diff --git a/scripts/advanced.php b/scripts/advanced.php index 0e770e3..36f6502 100644 --- a/scripts/advanced.php +++ b/scripts/advanced.php @@ -1,158 +1,158 @@ /dev/null 2>&1 &'); -} -} + if(isset($_POST["caddy_pwd"])) { + $caddy_pwd = $_POST["caddy_pwd"]; + if(strcmp($caddy_pwd,$config['CADDY_PWD']) !== 0) { + $contents = preg_replace("/CADDY_PWD=.*/", "CADDY_PWD=$caddy_pwd", $contents); + $contents2 = preg_replace("/CADDY_PWD=.*/", "CADDY_PWD=$caddy_pwd", $contents2); + $fh = fopen("/home/pi/BirdNET-Pi/birdnet.conf", "w"); + $fh2 = fopen("/home/pi/BirdNET-Pi/thisrun.txt", "w"); + fwrite($fh, $contents); + fwrite($fh2, $contents2); + exec('sudo /usr/local/bin/update_caddyfile.sh > /dev/null 2>&1 &'); + } + } -if(isset($_POST["db_pwd"])) { -$db_pwd = $_POST["db_pwd"]; -if(strcmp($db_pwd,$config['DB_PWD']) !== 0) { -shell_exec('sudo /usr/local/bin/update_db_pwd_bullseye.sh'); -$contents = preg_replace("/DB_PWD=.*/", "DB_PWD=$db_pwd", $contents); -$contents2 = preg_replace("/DB_PWD=.*/", "DB_PWD=$db_pwd", $contents2); -} -} + if(isset($_POST["db_pwd"])) { + $db_pwd = $_POST["db_pwd"]; + if(strcmp($db_pwd,$config['DB_PWD']) !== 0) { + shell_exec('sudo /usr/local/bin/update_db_pwd_bullseye.sh'); + $contents = preg_replace("/DB_PWD=.*/", "DB_PWD=$db_pwd", $contents); + $contents2 = preg_replace("/DB_PWD=.*/", "DB_PWD=$db_pwd", $contents2); + } + } -if(isset($_POST["ice_pwd"])) { -$ice_pwd = $_POST["ice_pwd"]; -if(strcmp($ice_pwd,$config['ICE_PWD']) !== 0) { -$contents = preg_replace("/ICE_PWD=.*/", "ICE_PWD=$ice_pwd", $contents); -$contents2 = preg_replace("/ICE_PWD=.*/", "ICE_PWD=$ice_pwd", $contents2); -} -} + if(isset($_POST["ice_pwd"])) { + $ice_pwd = $_POST["ice_pwd"]; + if(strcmp($ice_pwd,$config['ICE_PWD']) !== 0) { + $contents = preg_replace("/ICE_PWD=.*/", "ICE_PWD=$ice_pwd", $contents); + $contents2 = preg_replace("/ICE_PWD=.*/", "ICE_PWD=$ice_pwd", $contents2); + } + } -if(isset($_POST["birdnetpi_url"])) { -$birdnetpi_url = $_POST["birdnetpi_url"]; -if(strcmp($birdnetpi_url,$config['BIRDNETPI_URL']) !== 0) { -$contents = preg_replace("/BIRDNETPI_URL=.*/", "BIRDNETPI_URL=$birdnetpi_url", $contents); -$contents2 = preg_replace("/BIRDNETPI_URL=.*/", "BIRDNETPI_URL=$birdnetpi_url", $contents2); -$fh = fopen("/home/pi/BirdNET-Pi/birdnet.conf", "w"); -$fh2 = fopen("/home/pi/BirdNET-Pi/thisrun.txt", "w"); -fwrite($fh, $contents); -fwrite($fh2, $contents2); -exec('sudo /usr/local/bin/update_caddyfile.sh > /dev/null 2>&1 &'); -} -} + if(isset($_POST["birdnetpi_url"])) { + $birdnetpi_url = $_POST["birdnetpi_url"]; + if(strcmp($birdnetpi_url,$config['BIRDNETPI_URL']) !== 0) { + $contents = preg_replace("/BIRDNETPI_URL=.*/", "BIRDNETPI_URL=$birdnetpi_url", $contents); + $contents2 = preg_replace("/BIRDNETPI_URL=.*/", "BIRDNETPI_URL=$birdnetpi_url", $contents2); + $fh = fopen("/home/pi/BirdNET-Pi/birdnet.conf", "w"); + $fh2 = fopen("/home/pi/BirdNET-Pi/thisrun.txt", "w"); + fwrite($fh, $contents); + fwrite($fh2, $contents2); + exec('sudo /usr/local/bin/update_caddyfile.sh > /dev/null 2>&1 &'); + } + } -if(isset($_POST["webterminal_url"])) { -$webterminal_url = $_POST["webterminal_url"]; -if(strcmp($webterminal_url,$config['WEBTERMINAL_URL']) !== 0) { -$contents = preg_replace("/WEBTERMINAL_URL=.*/", "WEBTERMINAL_URL=$webterminal_url", $contents); -$contents2 = preg_replace("/WEBTERMINAL_URL=.*/", "WEBTERMINAL_URL=$webterminal_url", $contents2); -$fh = fopen("/home/pi/BirdNET-Pi/birdnet.conf", "w"); -$fh2 = fopen("/home/pi/BirdNET-Pi/thisrun.txt", "w"); -fwrite($fh, $contents); -fwrite($fh2, $contents2); -exec('sudo /usr/local/bin/update_caddyfile.sh > /dev/null 2>&1 &'); -} -} + if(isset($_POST["webterminal_url"])) { + $webterminal_url = $_POST["webterminal_url"]; + if(strcmp($webterminal_url,$config['WEBTERMINAL_URL']) !== 0) { + $contents = preg_replace("/WEBTERMINAL_URL=.*/", "WEBTERMINAL_URL=$webterminal_url", $contents); + $contents2 = preg_replace("/WEBTERMINAL_URL=.*/", "WEBTERMINAL_URL=$webterminal_url", $contents2); + $fh = fopen("/home/pi/BirdNET-Pi/birdnet.conf", "w"); + $fh2 = fopen("/home/pi/BirdNET-Pi/thisrun.txt", "w"); + fwrite($fh, $contents); + fwrite($fh2, $contents2); + exec('sudo /usr/local/bin/update_caddyfile.sh > /dev/null 2>&1 &'); + } + } -if(isset($_POST["birdnetlog_url"])) { -$birdnetlog_url = $_POST["birdnetlog_url"]; -if(strcmp($birdnetlog_url,$config['BIRDNETLOG_URL']) !== 0) { -$contents = preg_replace("/BIRDNETLOG_URL=.*/", "BIRDNETLOG_URL=$birdnetlog_url", $contents); -$contents2 = preg_replace("/BIRDNETLOG_URL=.*/", "BIRDNETLOG_URL=$birdnetlog_url", $contents2); -$fh = fopen("/home/pi/BirdNET-Pi/birdnet.conf", "w"); -$fh2 = fopen("/home/pi/BirdNET-Pi/thisrun.txt", "w"); -fwrite($fh, $contents); -fwrite($fh2, $contents2); -exec('sudo /usr/local/bin/update_caddyfile.sh > /dev/null 2>&1 &'); -} -} + if(isset($_POST["birdnetlog_url"])) { + $birdnetlog_url = $_POST["birdnetlog_url"]; + if(strcmp($birdnetlog_url,$config['BIRDNETLOG_URL']) !== 0) { + $contents = preg_replace("/BIRDNETLOG_URL=.*/", "BIRDNETLOG_URL=$birdnetlog_url", $contents); + $contents2 = preg_replace("/BIRDNETLOG_URL=.*/", "BIRDNETLOG_URL=$birdnetlog_url", $contents2); + $fh = fopen("/home/pi/BirdNET-Pi/birdnet.conf", "w"); + $fh2 = fopen("/home/pi/BirdNET-Pi/thisrun.txt", "w"); + fwrite($fh, $contents); + fwrite($fh2, $contents2); + exec('sudo /usr/local/bin/update_caddyfile.sh > /dev/null 2>&1 &'); + } + } -if(isset($_POST["overlap"])) { -$overlap = $_POST["overlap"]; -if(strcmp($overlap,$config['OVERLAP']) !== 0) { -$contents = preg_replace("/OVERLAP=.*/", "OVERLAP=$overlap", $contents); -$contents2 = preg_replace("/OVERLAP=.*/", "OVERLAP=$overlap", $contents2); -} -} + if(isset($_POST["overlap"])) { + $overlap = $_POST["overlap"]; + if(strcmp($overlap,$config['OVERLAP']) !== 0) { + $contents = preg_replace("/OVERLAP=.*/", "OVERLAP=$overlap", $contents); + $contents2 = preg_replace("/OVERLAP=.*/", "OVERLAP=$overlap", $contents2); + } + } -if(isset($_POST["confidence"])) { -$confidence = $_POST["confidence"]; -if(strcmp($confidence,$config['CONFIDENCE']) !== 0) { -$contents = preg_replace("/CONFIDENCE=.*/", "CONFIDENCE=$confidence", $contents); -$contents2 = preg_replace("/CONFIDENCE=.*/", "CONFIDENCE=$confidence", $contents2); -} -} + if(isset($_POST["confidence"])) { + $confidence = $_POST["confidence"]; + if(strcmp($confidence,$config['CONFIDENCE']) !== 0) { + $contents = preg_replace("/CONFIDENCE=.*/", "CONFIDENCE=$confidence", $contents); + $contents2 = preg_replace("/CONFIDENCE=.*/", "CONFIDENCE=$confidence", $contents2); + } + } -if(isset($_POST["sensitivity"])) { -$sensitivity = $_POST["sensitivity"]; -if(strcmp($sensitivity,$config['SENSITIVITY']) !== 0) { -$contents = preg_replace("/SENSITIVITY=.*/", "SENSITIVITY=$sensitivity", $contents); -$contents2 = preg_replace("/SENSITIVITY=.*/", "SENSITIVITY=$sensitivity", $contents2); -} -} + if(isset($_POST["sensitivity"])) { + $sensitivity = $_POST["sensitivity"]; + if(strcmp($sensitivity,$config['SENSITIVITY']) !== 0) { + $contents = preg_replace("/SENSITIVITY=.*/", "SENSITIVITY=$sensitivity", $contents); + $contents2 = preg_replace("/SENSITIVITY=.*/", "SENSITIVITY=$sensitivity", $contents2); + } + } -if(isset($_POST["full_disk"])) { -$full_disk = $_POST["full_disk"]; -if(strcmp($full_disk,$config['FULL_DISK']) !== 0) { -$contents = preg_replace("/FULL_DISK=.*/", "FULL_DISK=$full_disk", $contents); -$contents2 = preg_replace("/FULL_DISK=.*/", "FULL_DISK=$full_disk", $contents2); -} -} + if(isset($_POST["full_disk"])) { + $full_disk = $_POST["full_disk"]; + if(strcmp($full_disk,$config['FULL_DISK']) !== 0) { + $contents = preg_replace("/FULL_DISK=.*/", "FULL_DISK=$full_disk", $contents); + $contents2 = preg_replace("/FULL_DISK=.*/", "FULL_DISK=$full_disk", $contents2); + } + } -if(isset($_POST["rec_card"])) { -$rec_card = $_POST["rec_card"]; -if(strcmp($rec_card,$config['REC_CARD']) !== 0) { -$contents = preg_replace("/REC_CARD=.*/", "REC_CARD=$rec_card", $contents); -$contents2 = preg_replace("/REC_CARD=.*/", "REC_CARD=$rec_card", $contents2); -} -} + if(isset($_POST["rec_card"])) { + $rec_card = $_POST["rec_card"]; + if(strcmp($rec_card,$config['REC_CARD']) !== 0) { + $contents = preg_replace("/REC_CARD=.*/", "REC_CARD=$rec_card", $contents); + $contents2 = preg_replace("/REC_CARD=.*/", "REC_CARD=$rec_card", $contents2); + } + } -if(isset($_POST["channels"])) { -$channels = $_POST["channels"]; -if(strcmp($channels,$config['CHANNELS']) !== 0) { -$contents = preg_replace("/CHANNELS=.*/", "CHANNELS=$channels", $contents); -$contents2 = preg_replace("/CHANNELS=.*/", "CHANNELS=$channels", $contents2); -} -} + if(isset($_POST["channels"])) { + $channels = $_POST["channels"]; + if(strcmp($channels,$config['CHANNELS']) !== 0) { + $contents = preg_replace("/CHANNELS=.*/", "CHANNELS=$channels", $contents); + $contents2 = preg_replace("/CHANNELS=.*/", "CHANNELS=$channels", $contents2); + } + } -if(isset($_POST["recording_length"])) { -$recording_length = $_POST["recording_length"]; -if(strcmp($recording_length,$config['RECORDING_LENGTH']) !== 0) { -$contents = preg_replace("/RECORDING_LENGTH=.*/", "RECORDING_LENGTH=$recording_length", $contents); -$contents2 = preg_replace("/RECORDING_LENGTH=.*/", "RECORDING_LENGTH=$recording_length", $contents2); -} -} + if(isset($_POST["recording_length"])) { + $recording_length = $_POST["recording_length"]; + if(strcmp($recording_length,$config['RECORDING_LENGTH']) !== 0) { + $contents = preg_replace("/RECORDING_LENGTH=.*/", "RECORDING_LENGTH=$recording_length", $contents); + $contents2 = preg_replace("/RECORDING_LENGTH=.*/", "RECORDING_LENGTH=$recording_length", $contents2); + } + } -if(isset($_POST["extraction_length"])) { -$extraction_length = $_POST["extraction_length"]; -if(strcmp($extraction_length,$config['EXTRACTION_LENGTH']) !== 0) { -$contents = preg_replace("/EXTRACTION_LENGTH=.*/", "EXTRACTION_LENGTH=$extraction_length", $contents); -$contents2 = preg_replace("/EXTRACTION_LENGTH=.*/", "EXTRACTION_LENGTH=$extraction_length", $contents2); -} -} + if(isset($_POST["extraction_length"])) { + $extraction_length = $_POST["extraction_length"]; + if(strcmp($extraction_length,$config['EXTRACTION_LENGTH']) !== 0) { + $contents = preg_replace("/EXTRACTION_LENGTH=.*/", "EXTRACTION_LENGTH=$extraction_length", $contents); + $contents2 = preg_replace("/EXTRACTION_LENGTH=.*/", "EXTRACTION_LENGTH=$extraction_length", $contents2); + } + } -$fh = fopen("/home/pi/BirdNET-Pi/birdnet.conf", "w"); -$fh2 = fopen("/home/pi/BirdNET-Pi/thisrun.txt", "w"); -fwrite($fh, $contents); -fwrite($fh2, $contents2); -@session_start(); -if(true){ - $_SESSION['success'] = 1; -} + $fh = fopen("/home/pi/BirdNET-Pi/birdnet.conf", "w"); + $fh2 = fopen("/home/pi/BirdNET-Pi/thisrun.txt", "w"); + fwrite($fh, $contents); + fwrite($fh2, $contents2); + @session_start(); + if(true){ + $_SESSION['success'] = 1; + } } ?> @@ -249,9 +249,9 @@ input {

Advanced Settings

@@ -265,14 +265,14 @@ if (file_exists('/home/pi/BirdNET-Pi/thisrun.txt')) { >Purge + if (strcmp($newconfig['FULL_DISK'], "keep") == 0) { + echo "checked"; + }?>>Keep

When the disk becomes full, you can choose to 'purge' old files to make room for new ones or 'keep' your data and stop all services instead.


@@ -282,7 +282,7 @@ if (strcmp($newconfig['FULL_DISK'], "keep") == 0) {

Set Channels to the number of channels supported by your sound card. 32 max.


-

Set Recording Length in seconds between 6 and 60. Multiples of 3 are recommended, as BirdNET analyzes in 3-second chunks.

+

Set Recording Length in seconds between 6 and 60. Multiples of 3 are recommended, as BirdNET analyzes in 3-second chunks.


Set Extraction Length to something less than your Recording Length above. Min=3 Max=Recording Length @@ -321,12 +321,12 @@ if (strcmp($newconfig['FULL_DISK'], "keep") == 0) {


diff --git a/scripts/backup_data.php b/scripts/backup_data.php deleted file mode 100644 index c6587be..0000000 --- a/scripts/backup_data.php +++ /dev/null @@ -1,4 +0,0 @@ - /tmp/birdnetbackup.log 2&>1"); -header('Location: /backup_inprogress.html'); -?> diff --git a/scripts/backup_data.sh b/scripts/backup_data.sh deleted file mode 100755 index 2379fde..0000000 --- a/scripts/backup_data.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -# Tar and compress all data -source /etc/birdnet/birdnet.conf - -tar -czvf /home/pi/BirdNET-Pi/BirdNET-Pi_Data_Dump_$(date +%F).tar.gz ${EXTRACTED} /home/pi/BirdNET-Pi/BirdDB.txt diff --git a/scripts/restart_birdnet_analysis.php b/scripts/restart_birdnet_analysis.php index 2bca34d..f381d8b 100644 --- a/scripts/restart_birdnet_analysis.php +++ b/scripts/restart_birdnet_analysis.php @@ -1,4 +1,4 @@ diff --git a/scripts/stop_core_services.php b/scripts/stop_core_services.php index e335b68..28c09ad 100644 --- a/scripts/stop_core_services.php +++ b/scripts/stop_core_services.php @@ -1,4 +1,4 @@ diff --git a/scripts/update_birdnet.php b/scripts/update_birdnet.php index a5d5b44..892fa42 100644 --- a/scripts/update_birdnet.php +++ b/scripts/update_birdnet.php @@ -1,4 +1,4 @@ /tmp/phpupdate.log 2&>1"); -header('Location: http://birdnetpi.local/scripts/update_inprogress.php'); +header('Location: /update_inprogress.php'); ?> diff --git a/templates/Caddyfile_livestream b/templates/Caddyfile_livestream deleted file mode 100644 index 53f522b..0000000 --- a/templates/Caddyfile_livestream +++ /dev/null @@ -1,17 +0,0 @@ -http://birdnetpi.local ${BIRDNETPI_URL} { - root * ${EXTRACTED} - file_server browse - basicauth ${PROCESSED}* { - birdnet ${HASHWORD} - } - basicauth /stream { - birdnet ${HASHWORD} - } - reverse_proxy /stream localhost:8000 -} -http://birdlog.local { - reverse_proxy localhost:8080 -} -http://extractionlog.local { - reverse_proxy localhost:8888 -} diff --git a/templates/Caddyfile_nostream b/templates/Caddyfile_nostream deleted file mode 100644 index f60161f..0000000 --- a/templates/Caddyfile_nostream +++ /dev/null @@ -1,16 +0,0 @@ -http://birdnetpi.local ${BIRDNETPI_URL} { - root * ${EXTRACTED} - file_server browse - basicauth ${PROCESSED}* { - birdnet ${HASHWORD} - } - basicauth /stream { - birdnet ${HASHWORD} - } -} -http://birdlog.local { - reverse_proxy localhost:8080 -} -http://extractionlog.local { - reverse_proxy localhost:8888 -}