Skip to content

A live bird collage card for your Home Assistant dashboard.

adding new php scripts

Patrick McGuirefe6561374c08
diff --git a/scripts/extract_new_birdsounds.sh b/scripts/extract_new_birdsounds.sh
index fee138ee..a7ff4295 100755
--- a/scripts/extract_new_birdsounds.sh
+++ b/scripts/extract_new_birdsounds.sh
@@ -128,16 +128,14 @@ for h in "${SCAN_DIRS[@]}";do
# directory.
### TESTING longer extraction context
- set -x
[ -z ${EXTRACTION_LENGTH} ] && EXTRACTION_LENGTH=6
- SPACER=$(echo "(${EXTRACTION_LENGTH} - 3 )/2" |bc -l)
- START=$(echo "${START} - ${SPACER}"|bc -l)
- END=$(echo "${END} + ${SPACER}"|bc -l)
+ SPACER=$(echo "scale=1;(${EXTRACTION_LENGTH} - 3 )/2" |bc -l)
+ START=$(echo "scale=1;${START} - ${SPACER}"|bc -l)
+ END=$(echo "scale=1;${END} + ${SPACER}"|bc -l)
- if (( $(echo "${START} < 0" | bc -l) ));then START=0;fi
- if (( $(echo "${END} > ${RECORDING_LENGTH}" | bc -l) ));then END=${RECORDING_LENGTH};fi
+ if (( $(echo "scale=1;${START} < 1" | bc -l) ));then START=0;fi
+ if (( $(echo "scale=1;${END} > ${RECORDING_LENGTH}" | bc -l) ));then END=${RECORDING_LENGTH};fi
- set +x
ffmpeg -hide_banner -loglevel error -nostdin -i "${h}/${OLDFILE}" \
-acodec copy -ss "${START}" -to "${END}"\
"${NEWSPECIES_BYDATE}/${a}-${NEWFILE}"
diff --git a/scripts/index.html b/scripts/index.html
index 269ab833..0e158b24 100644
--- a/scripts/index.html
+++ b/scripts/index.html
@@ -1,7 +1,24 @@
<form action="/scripts/restart_services.php">
- <input type="submit" value="Restart BirdNET-system">
+ <input type="submit" value="Restart ALL BirdNET-system Services">
</form>
-<form action="/scripts/restart_services.php">
- <input type="submit" value="Restart BirdNET-system">
+<form action="/scripts/restart_birdnet_analysis.php">
+ <input type="submit" value="Restart BirdNET Analysis Service">
+</form>
+
+<form action="/scripts/restart_birdnet_recording.php">
+ <input type="submit" value="Restart Recording Service">
+</form>
+
+<form action="/scripts/restart_extraction.php">
+ <input type="submit" value="Restart Extraction Service">
</form>
+
+<form action="/scripts/restart_caddy.php">
+ <input type="submit" value="Restart Caddy">
+</form>
+
+<form action="/scripts/reboot_system.php">
+ <input type="submit" value="Reboot BirdNET-system">
+</form>
+
diff --git a/scripts/reboot_system.php b/scripts/reboot_system.php
new file mode 100644
index 00000000..2e385ad9
--- /dev/null
+++ b/scripts/reboot_system.php
@@ -0,0 +1,4 @@
+<?php
+shell_exec("/home/pi/BirdNET-Lite/scripts/reboot_system.sh");
+header('Location: http://birdnetsystem.local/scripts/index.html?success=true');
+?>
diff --git a/scripts/reboot_system.sh b/scripts/reboot_system.sh
new file mode 100755
index 00000000..e45727e0
--- /dev/null
+++ b/scripts/reboot_system.sh
@@ -0,0 +1,2 @@
+#!/usr/bin/env bash
+sudo reboot
diff --git a/scripts/restart_birdnet.sh b/scripts/restart_birdnet.sh
index cfc43a2b..e42cf34e 100755
--- a/scripts/restart_birdnet.sh
+++ b/scripts/restart_birdnet.sh
@@ -1,9 +1,23 @@
#!/usr/bin/env bash
-# Restart services
+# Restarts ALL services and removes ALL unprocessed audio
source /etc/birdnet/birdnet.conf
sudo systemctl stop birdnet_recording.service
sudo rm -rf ${RECS_DIR}/$(date +%B-%Y/%d-%A)/*
sudo systemctl start birdnet_recording.service
-sudo systemctl restart extraction.timer
-sudo systemctl restart birdnet_analysis.service
+
+birdnet_analysis.service
+birdnet_log.service
+birdstats.service
+extraction.timer
+extractionlog.service
+livestream.service)
+
+for i in "${SERVICES[@]}";do
+ sudo systemctl restart ${i}
+done
+
diff --git a/scripts/restart_birdnet_analysis.php b/scripts/restart_birdnet_analysis.php
new file mode 100644
index 00000000..2c050a1b
--- /dev/null
+++ b/scripts/restart_birdnet_analysis.php
@@ -0,0 +1,4 @@
+<?php
+shell_exec("/home/pi/BirdNET-Lite/scripts/restart_birdnet_analysis.sh");
+header('Location: http://birdnetsystem.local/scripts/index.html?success=true');
+?>
diff --git a/scripts/restart_birdnet_analysis.sh b/scripts/restart_birdnet_analysis.sh
new file mode 100755
index 00000000..c40b3e8e
--- /dev/null
+++ b/scripts/restart_birdnet_analysis.sh
@@ -0,0 +1,3 @@
+#!/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
new file mode 100644
index 00000000..9c61cd4c
--- /dev/null
+++ b/scripts/restart_birdnet_recording.php
@@ -0,0 +1,4 @@
+<?php
+shell_exec("/home/pi/BirdNET-Lite/scripts/restart_birdnet_recording.sh");
+header('Location: http://birdnetsystem.local/scripts/index.html?success=true');
+?>
diff --git a/scripts/restart_birdnet_recording.sh b/scripts/restart_birdnet_recording.sh
new file mode 100755
index 00000000..bc9f5b86
--- /dev/null
+++ b/scripts/restart_birdnet_recording.sh
@@ -0,0 +1,3 @@
+#!/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
new file mode 100644
index 00000000..3de0dd92
--- /dev/null
+++ b/scripts/restart_caddy.php
@@ -0,0 +1,4 @@
+<?php
+shell_exec("/home/pi/BirdNET-Lite/scripts/restart_caddy.sh");
+header('Location: http://birdnetsystem.local/scripts/index.html?success=true');
+?>
diff --git a/scripts/restart_caddy.sh b/scripts/restart_caddy.sh
new file mode 100755
index 00000000..43edcca4
--- /dev/null
+++ b/scripts/restart_caddy.sh
@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+# Restars the caddy webserver
+sudo systemctl restart caddy
diff --git a/scripts/restart_extraction.php b/scripts/restart_extraction.php
new file mode 100644
index 00000000..f847580f
--- /dev/null
+++ b/scripts/restart_extraction.php
@@ -0,0 +1,4 @@
+<?php
+shell_exec("/home/pi/BirdNET-Lite/scripts/restart_extraction.sh");
+header('Location: http://birdnetsystem.local/scripts/index.html?success=true');
+?>
diff --git a/scripts/restart_extraction.sh b/scripts/restart_extraction.sh
new file mode 100755
index 00000000..81aadf08
--- /dev/null
+++ b/scripts/restart_extraction.sh
@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+# Restars the BirdNET Extraction service
+sudo systemctl restart extraction.service