Skip to content

A live bird collage card for your Home Assistant dashboard.

removing unneeded scripts and adding extractions to logging

mcguirepr89073e718cacbe
diff --git a/scripts/birdnet_log.sh b/scripts/birdnet_log.sh
index 9c26d3e6..c170b915 100755
--- a/scripts/birdnet_log.sh
+++ b/scripts/birdnet_log.sh
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
-journalctl --no-hostname -o short -fu birdnet_analysis -u birdnet_server | sed "s/$(date "+%b %d ")//g"
+journalctl --no-hostname -o short -fu birdnet_analysis -ubirdnet_server -uextraction | sed "s/$(date "+%b %d ")//g"
diff --git a/scripts/clear_all_data.php b/scripts/clear_all_data.php
deleted file mode 100644
index b0be43d7..00000000
--- a/scripts/clear_all_data.php
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php
-shell_exec("/home/pi/BirdNET-Pi/scripts/clear_all_data.sh");
-header('Location: /viewdb.php');
-?>
diff --git a/scripts/extract_new_birdsounds.sh b/scripts/extract_new_birdsounds.sh
index 1fac41e8..6a90a8dc 100755
--- a/scripts/extract_new_birdsounds.sh
+++ b/scripts/extract_new_birdsounds.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# Exit when any command fails
-set -x
+#set -x
set -e
# Keep track of the last executed command
#trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG
diff --git a/scripts/reboot_system.php b/scripts/reboot_system.php
deleted file mode 100644
index e7f56d89..00000000
--- a/scripts/reboot_system.php
+++ /dev/null
@@ -1,3 +0,0 @@
-<?php
-shell_exec("/home/pi/BirdNET-Pi/scripts/reboot_system.sh");
-?>
diff --git a/scripts/reboot_system.sh b/scripts/reboot_system.sh
deleted file mode 100755
index e45727e0..00000000
--- a/scripts/reboot_system.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/usr/bin/env bash
-sudo reboot
diff --git a/scripts/reconfigure_birdnet.sh b/scripts/reconfigure_birdnet.sh
deleted file mode 100755
index a362fa9e..00000000
--- a/scripts/reconfigure_birdnet.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/env bash
-# Reconfigure the BirdNET-Pi
-source /etc/birdnet/birdnet.conf
-uninstall.sh
-${HOME}/BirdNET-Pi/scripts/install_config.sh
-USER=${USER} HOME=${HOME} sudo ${HOME}/BirdNET-Pi/scripts/install_services.sh
-echo "BirdNET-Pi has now been reconfigured."
diff --git a/scripts/reconfigure_birdnet_gui.sh b/scripts/reconfigure_birdnet_gui.sh
deleted file mode 100755
index 4f76522c..00000000
--- a/scripts/reconfigure_birdnet_gui.sh
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/usr/bin/bash
-# Writes variables to config file
-set -x
-birdnetpi_dir=/home/pi/BirdNET-Pi
-source ${birdnetpi_dir}/scripts/welcome_wizard.sh
-birdnet_conf=${birdnetpi_dir}/birdnet.conf
-
-rearview() {
- zenity --title="Configuration Complete!!" --width=300 --ok-label="Finished" --window-icon=/usr/share/pixmaps/red-cardinal32.png \
- --info --text="
-Caddy is reloading and the passwords are being updated.
-
-When the system is updated with your new information,
-the main web page will open automatically" --no-wrap --icon-name=red-cardinal
-}
-rearview &
-
-if ! [ -z ${new_lat} ];then
-sed -i s/'^LATITUDE=.*'/"LATITUDE=${new_lat}"/g ${birdnet_conf}
-fi
-
-if ! [ -z ${new_lon} ];then
-sed -i s/'^LONGITUDE=.*'/"LONGITUDE=${new_lon}"/g ${birdnet_conf}
-fi
-
-if ! [ -z ${caddy_pwd} ];then
-sed -i s/'^CADDY_PWD=.*'/"CADDY_PWD=${caddy_pwd}"/g ${birdnet_conf}
-hash_pwd=$(caddy hash-password -plaintext ${caddy_pwd})
-sudo sed -i s/'birdnet\ .*'/"birdnet ${hash_pwd}"/g /etc/caddy/Caddyfile
-sudo systemctl reload caddy
-fi
-
-if ! [ -z ${db_pwd} ];then
-sed -i s/'^DB_PWD=.*'/"DB_PWD=${db_pwd}"/g ${birdnet_conf}
-${birdnetpi_dir}/scripts/update_db_pwd_bullseye.sh
-fi
-
-if ! [ -z ${birdnetpi_url} ];then
-sed -i s/'^BIRDNETPI_URL=.*'/"BIRDNETPI_URL=${birdnetpi_url/\/\//\\\/\\\/}"/g ${birdnet_conf}
-sed -i s/'^WEBTERMINAL_URL=.*'/"WEBTERMINAL_URL=${extractionlog_url/\/\//\\\/\\\/}"/g ${birdnet_conf}
-sed -i s/'^BIRDNETLOG_URL=.*'/"BIRDNETLOG_URL=${birdnetlog_url/\/\//\\\/\\\/}"/g ${birdnet_conf}
-fi
-
-if ! [ -z ${new_sensitivity} ];then
-sed -i s/'^SENSITIVITY=.*'/"SENSITIVITY=${new_sensitivity}"/g ${birdnet_conf}
-fi
-
-if ! [ -z ${new_confidence} ];then
-sed -i s/'^CONFIDENCE=.*'/"CONFIDENCE=${new_confidence}"/g ${birdnet_conf}
-fi
-
-${birdnetpi_dir}/scripts/update_birdnet.sh
-sudo apt install -y --reinstall icecast2
-xdg-open http://birdnetpi.local
-systemctl --user disable birdnet-pi-welcome-wizard.service
diff --git a/scripts/restart_birdnet_analysis.php b/scripts/restart_birdnet_analysis.php
deleted file mode 100644
index f381d8b2..00000000
--- a/scripts/restart_birdnet_analysis.php
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php
-shell_exec("/home/pi/BirdNET-Pi/scripts/restart_birdnet_analysis.sh");
-header("Location: /overview.php");
-?>
diff --git a/scripts/restart_birdnet_analysis.sh b/scripts/restart_birdnet_analysis.sh
deleted file mode 100755
index c40b3e8e..00000000
--- a/scripts/restart_birdnet_analysis.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env bash
-# Restars the main BirdNET analysis service
-sudo systemctl restart birdnet_analysis.service
diff --git a/scripts/restart_birdnet_recording.php b/scripts/restart_birdnet_recording.php
deleted file mode 100644
index 1712058d..00000000
--- a/scripts/restart_birdnet_recording.php
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php
-shell_exec("/home/pi/BirdNET-Pi/scripts/restart_birdnet_recording.sh");
-header('Location: /viewdb.php');
-?>
diff --git a/scripts/restart_birdnet_recording.sh b/scripts/restart_birdnet_recording.sh
deleted file mode 100755
index bc9f5b86..00000000
--- a/scripts/restart_birdnet_recording.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env bash
-# Restars the BirdNET Recording service
-sudo systemctl restart birdnet_recording.service
diff --git a/scripts/restart_caddy.php b/scripts/restart_caddy.php
deleted file mode 100644
index fa9f6d25..00000000
--- a/scripts/restart_caddy.php
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php
-shell_exec("/home/pi/BirdNET-Pi/scripts/restart_caddy.sh");
-header('Location: /viewdb.php');
-?>
diff --git a/scripts/restart_caddy.sh b/scripts/restart_caddy.sh
deleted file mode 100755
index 43edcca4..00000000
--- a/scripts/restart_caddy.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env bash
-# Restars the caddy webserver
-sudo systemctl restart caddy
diff --git a/scripts/restart_extraction.php b/scripts/restart_extraction.php
deleted file mode 100644
index f52aa58a..00000000
--- a/scripts/restart_extraction.php
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php
-shell_exec("/home/pi/BirdNET-Pi/scripts/restart_extraction.sh");
-header('Location: http://birdnetpi.local:8888');
-?>
diff --git a/scripts/restart_extraction.sh b/scripts/restart_extraction.sh
deleted file mode 100755
index 81aadf08..00000000
--- a/scripts/restart_extraction.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env bash
-# Restars the BirdNET Extraction service
-sudo systemctl restart extraction.service
diff --git a/scripts/restart_services.php b/scripts/restart_services.php
deleted file mode 100644
index ba15664c..00000000
--- a/scripts/restart_services.php
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php
-shell_exec("/home/pi/BirdNET-Pi/scripts/restart_services.sh");
-header('Location: http://birdnetpi.local:8080');
-?>
diff --git a/scripts/service_controls.php b/scripts/service_controls.php
index 33c6f862..348c9572 100644
--- a/scripts/service_controls.php
+++ b/scripts/service_controls.php
@@ -59,24 +59,39 @@ a {
<body style="background-color: rgb(119, 196, 135);">
<div class="row">
<div class="column first">
- <form action="/scripts/stop_core_services.php" onclick="return confirm('Stop core services?')">
+ <form action="" method="POST" onclick="return confirm('Stop core services?')">
+ <input type="hidden" name="submit" value="stop_core_services.sh">
<button type="submit" class="block">Stop Core Services</button>
</form>
- <form action="/scripts/restart_services.php" onclick="return confirm('Restart ALL services?')">
+ <form action="" method="POST" onclick="return confirm('Restart ALL services?')">
+ <input type="hidden" name="submit" value="restart_services.sh">
<button type="submit" class="block">Restart ALL Services</button>
</form>
- <form action="/scripts/restart_birdnet_analysis.php">
+ <form action="" method="POST">
+ <input type="hidden" name="submit" value="sudo systemctl restart birdnet_analysis.service">
<button type="submit" class="block">Restart BirdNET Analysis</button>
</form>
- <form action="/scripts/restart_birdnet_recording.php">
+ <form action="" method="POST">
+ <input type="hidden" name="submit" value="sudo systemctl restart birdnet_recording.service">
<button type="submit" class="block">Restart Recording</button>
</form>
- <form action="/scripts/restart_extraction.php">
- <button type="submit" class="block">Restart Extraction</button>
- </form>
- <form action="/scripts/restart_caddy.php" onclick="return confirm('Restart Caddy? You will be disconnected for about 20 seconds.')">
+ <form action="" method="POST" onclick="return confirm('Restart Caddy? You will be disconnected for about 20 seconds.')">
+ <input type="hidden" name="submit" value="sudo systemctl restart caddy">
<button type="submit" class="block">Restart Caddy</button>
</form>
</div>
+ <div class="column second">
+<?php
+ini_set('display_errors', 1);
+ini_set('display_startup_errors', 1);
+error_reporting(E_ALL);
+
+if(isset($_POST['submit'])){
+$command = $_POST['submit'];
+echo "<h3>Executed $command</h3>";
+shell_exec("$command");
+}
+?>
+ </div>
</div>
</body>
diff --git a/scripts/shutdown_system.php b/scripts/shutdown_system.php
deleted file mode 100644
index 74ce980b..00000000
--- a/scripts/shutdown_system.php
+++ /dev/null
@@ -1,3 +0,0 @@
-<?php
-shell_exec("/home/pi/BirdNET-Pi/scripts/shutdown_system.sh");
-?>
diff --git a/scripts/shutdown_system.sh b/scripts/shutdown_system.sh
deleted file mode 100755
index d2eff34e..00000000
--- a/scripts/shutdown_system.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/usr/bin/env bash
-sudo shutdown now
diff --git a/scripts/stop_core_services.php b/scripts/stop_core_services.php
deleted file mode 100644
index 28c09ad9..00000000
--- a/scripts/stop_core_services.php
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php
-shell_exec("/home/pi/BirdNET-Pi/scripts/stop_core_services.sh");
-header('Location: /overview.php');
-?>
diff --git a/scripts/system_controls.php b/scripts/system_controls.php
index 16f419f0..2034dc0d 100644
--- a/scripts/system_controls.php
+++ b/scripts/system_controls.php
@@ -59,17 +59,30 @@ a {
<body style="background-color: rgb(119, 196, 135);">
<div class="row">
<div class="column first">
- <form action="/scripts/reboot_system.php" onclick="return confirm('Are you sure you want to reboot?')">
+ <form action="" method="POST" onclick="return confirm('Are you sure you want to reboot?')">
+ <input type="hidden" name="submit" value="sudo reboot">
<button type="submit" class="block">Reboot</button>
</form>
- <form action="/scripts/update_birdnet.php" onclick="return confirm('BE SURE TO STASH ANY LOCAL CHANGES YOU HAVE MADE TO THE SYSTEM BEFORE UPDATING!!!')">
+ <form action="" method="POST" onclick="return confirm('BE SURE TO STASH ANY LOCAL CHANGES YOU HAVE MADE TO THE SYSTEM BEFORE UPDATING!!!')">
+ <input type="hidden" name="submit" value="update_birdnet.sh">
<button style="color:blue;" type="submit" class="block">Update</button>
</form>
- <form action="/scripts/shutdown_system.php" onclick="return confirm('Are you sure you want to shutdown?')">
+ <form action="" method="POST" onclick="return confirm('Are you sure you want to shutdown?')">
+ <input type="hidden" name="submit" value="sudo shutdown now">
<button style="color: red;" type="submit" class="block">Shutdown</button>
</form>
- <form action="/scripts/clear_all_data.php" onclick="return confirm('Clear ALL Data? This cannot be undone.')">
+ <form action="" method="POST" onclick="return confirm('Clear ALL Data? This cannot be undone.')">
+ <input type="hidden" name="submit" value="clear_all_data.sh">
<button style="color: red;" type="submit" class="block">Clear ALL data</button>
</form>
</div>
+ <div class="column second">
+<?php
+if(isset($_POST['submit'])){
+ $command = $_POST['submit'];
+ echo "<h3>Executing $command</h3>";
+ shell_exec("$command");
+}
+?>
+ </div>
</body>
diff --git a/scripts/update_birdnet.php b/scripts/update_birdnet.php
deleted file mode 100644
index 413b337a..00000000
--- a/scripts/update_birdnet.php
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php
-shell_exec("sudo -u pi /home/pi/BirdNET-Pi/scripts/update_birdnet.sh > /tmp/phpupdate.log 2&>1");
-header('Location: update_inprogress.php');
-?>