tweaks and fixes

This commit is contained in:
mcguirepr89
2022-03-03 14:50:37 -05:00
parent d124e108fb
commit e08180ff7d
4 changed files with 24 additions and 23 deletions
+13 -10
View File
@@ -1,10 +1,10 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style.css"> <link rel="stylesheet" href="style.css">
<div class="banner"> <div class="banner">
<div class="logo"> <div class="logo">
<a href="https://github.com/mcguirepr89/BirdNET-Pi.git" target="_blank"><img src="images/bird.png"></a> <a href="https://github.com/mcguirepr89/BirdNET-Pi.git" target="_blank"><img src="images/bird.png"></a>
</div> </div>
<?php <?php
echo "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">";
if(isset($_GET['stream'])){ if(isset($_GET['stream'])){
if (file_exists('/home/pi/BirdNET-Pi/thisrun.txt')) { if (file_exists('/home/pi/BirdNET-Pi/thisrun.txt')) {
$config = parse_ini_file('/home/pi/BirdNET-Pi/thisrun.txt'); $config = parse_ini_file('/home/pi/BirdNET-Pi/thisrun.txt');
@@ -21,7 +21,8 @@ if (!isset($_SERVER['PHP_AUTH_USER'])) {
$submittedpwd = $_SERVER['PHP_AUTH_PW']; $submittedpwd = $_SERVER['PHP_AUTH_PW'];
$submitteduser = $_SERVER['PHP_AUTH_USER']; $submitteduser = $_SERVER['PHP_AUTH_USER'];
if($submittedpwd == $caddypwd && $submitteduser == 'birdnet'){ if($submittedpwd == $caddypwd && $submitteduser == 'birdnet'){
echo "<audio controls autoplay><source src=\"/stream\"></audio> echo "
<audio controls autoplay><source src=\"/stream\"></audio>
<h1><a href=\"\">BirdNET-Pi</a></h1>"; <h1><a href=\"\">BirdNET-Pi</a></h1>";
} else { } else {
header('WWW-Authenticate: Basic realm="My Realm"'); header('WWW-Authenticate: Basic realm="My Realm"');
@@ -31,12 +32,13 @@ if (!isset($_SERVER['PHP_AUTH_USER'])) {
} }
} }
} else { } else {
echo "<form action=\"\" method=\"GET\"> echo "
<form action=\"\" method=\"GET\">
<button type=\"submit\" name=\"stream\" value=\"play\">Live Audio</button> <button type=\"submit\" name=\"stream\" value=\"play\">Live Audio</button>
</form>"; </form>
echo "<h1><a href=\"\">BirdNET-Pi</a></h1>"; <h1><a href=\"\">BirdNET-Pi</a></h1>
</div>";
} }
echo "</div>";
if(isset($_GET['log'])) { if(isset($_GET['log'])) {
if (file_exists('/home/pi/BirdNET-Pi/thisrun.txt')) { if (file_exists('/home/pi/BirdNET-Pi/thisrun.txt')) {
$config = parse_ini_file('/home/pi/BirdNET-Pi/thisrun.txt'); $config = parse_ini_file('/home/pi/BirdNET-Pi/thisrun.txt');
@@ -61,5 +63,6 @@ if(isset($_GET['log'])) {
} elseif(isset($_GET['spectrogram'])){ } elseif(isset($_GET['spectrogram'])){
header("Location: /spectrogram.php"); header("Location: /spectrogram.php");
} else { } else {
echo "<iframe src=\"/views.php\">"; echo "
<iframe src=\"/views.php\">";
} }
+2
View File
@@ -213,6 +213,7 @@ install_Caddyfile() {
cat << EOF > /etc/caddy/Caddyfile cat << EOF > /etc/caddy/Caddyfile
http://localhost http://$(hostname).local ${BIRDNETPI_URL} { http://localhost http://$(hostname).local ${BIRDNETPI_URL} {
root * ${EXTRACTED} root * ${EXTRACTED}
file_server browse
handle /By_Date/* { handle /By_Date/* {
file_server browse file_server browse
} }
@@ -239,6 +240,7 @@ EOF
cat << EOF > /etc/caddy/Caddyfile cat << EOF > /etc/caddy/Caddyfile
http://localhost http://$(hostname).local ${BIRDNETPI_URL} { http://localhost http://$(hostname).local ${BIRDNETPI_URL} {
root * ${EXTRACTED} root * ${EXTRACTED}
file_server browse
handle /By_Date/* { handle /By_Date/* {
file_server browse file_server browse
} }
+7
View File
@@ -13,6 +13,7 @@ HASHWORD=$(caddy hash-password -plaintext ${CADDY_PWD})
cat << EOF > /etc/caddy/Caddyfile cat << EOF > /etc/caddy/Caddyfile
http://localhost http://$(hostname).local ${BIRDNETPI_URL} { http://localhost http://$(hostname).local ${BIRDNETPI_URL} {
root * ${EXTRACTED} root * ${EXTRACTED}
file_server browse
handle /By_Date/* { handle /By_Date/* {
file_server browse file_server browse
} }
@@ -40,6 +41,12 @@ else
http://localhost http://$(hostname).local ${BIRDNETPI_URL} { http://localhost http://$(hostname).local ${BIRDNETPI_URL} {
root * ${EXTRACTED} root * ${EXTRACTED}
file_server browse file_server browse
handle /By_Date/* {
file_server browse
}
handle /Charts/* {
file_server browse
}
reverse_proxy /stream localhost:8000 reverse_proxy /stream localhost:8000
php_fastcgi unix//run/php/php7.4-fpm.sock php_fastcgi unix//run/php/php7.4-fpm.sock
} }
-11
View File
@@ -1,11 +0,0 @@
[Unit]
Description=BirdNET-Pi Live Stream
[Service]
Environment=XDG_RUNTIME_DIR=/run/user/1000
Restart=always
Type=simple
RestartSec=3
User=${BIRDNET_USER}
ExecStart=ffmpeg -loglevel 52 -ac 2 -f alsa -i ${REC_CARD} -acodec libmp3lame -b:a 320k -ac 2 -content_type 'audio/mpeg' -f mp3 icecast://source:${ICE_PWD}@localhost:8000/stream -re
[Install]
WantedBy=multi-user.target