mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-07-08 23:10:59 +02:00
Update 03_throttlerecording
This commit is contained in:
@@ -1,8 +1,11 @@
|
|||||||
#!/bin/bash
|
#!/command/with-contenv bashio
|
||||||
|
# shellcheck shell=bash
|
||||||
#
|
#
|
||||||
# Stop the recordings while the analysis catches up https://github.com/mcguirepr89/BirdNET-Pi/issues/393#issuecomment-1166445710
|
# Stop the recordings while the analysis catches up
|
||||||
|
# Adapted from https://github.com/mcguirepr89/BirdNET-Pi/issues/393#issuecomment-1166445710
|
||||||
#
|
#
|
||||||
echo "Starting service: throttlerecording"
|
echo "Starting service: throttlerecording"
|
||||||
|
touch "$HOME"/BirdSongs/StreamData/analyzing_now.txt
|
||||||
|
|
||||||
source /config/birdnet.conf
|
source /config/birdnet.conf
|
||||||
srv="birdnet_recording"
|
srv="birdnet_recording"
|
||||||
@@ -11,19 +14,19 @@ counter=10
|
|||||||
while [ 1 ];do
|
while [ 1 ];do
|
||||||
sleep 61
|
sleep 61
|
||||||
if [ $counter -le 0 ];then
|
if [ $counter -le 0 ];then
|
||||||
latest=$(cat "$HOME"/BirdNET-Pi/analyzing_now.txt)
|
latest=$(cat "$RECS_DIR"/StreamData/analyzing_now.txt)
|
||||||
if [ "$latest" = "$analyzing_now" ];then
|
if [ "$latest" = "$analyzing_now" ];then
|
||||||
echo "$(date) WARNING no change in analyzing_now for 10 iterations, restarting services"
|
echo "$(date) WARNING no change in analyzing_now for 10 iterations, restarting services"
|
||||||
"$HOME"/BirdNET-Pi/scripts/restart_services.sh
|
"$HOME"/BirdNET-Pi/scripts/restart_services.sh
|
||||||
fi
|
fi
|
||||||
counter=10
|
counter=10
|
||||||
analyzing_now=$(cat "$HOME"/BirdNET-Pi/analyzing_now.txt)
|
analyzing_now=$(cat "$HOME"/BirdSongs/StreamData/analyzing_now.txt)
|
||||||
fi
|
fi
|
||||||
if [ -z "${RTSP_STREAM}" ];then
|
if [ -z "${RTSP_STREAM}" ];then
|
||||||
ingest_dir=${RECS_DIR}/$(date +"%B-%Y/%d-%A")
|
ingest_dir=${RECS_DIR}/$(date +"%B-%Y/%d-%A")
|
||||||
mkdir -p $ingest_dir
|
mkdir -p "$ingest_dir"
|
||||||
else
|
else
|
||||||
ingest_dir=$RECS_DIR/StreamData
|
ingest_dir="$RECS_DIR"/StreamData
|
||||||
fi
|
fi
|
||||||
wavs=$(ls ${ingest_dir}/*.wav | wc -l)
|
wavs=$(ls ${ingest_dir}/*.wav | wc -l)
|
||||||
if [ $(systemctl --state=active | grep $srv | wc -l) -eq 0 ];then
|
if [ $(systemctl --state=active | grep $srv | wc -l) -eq 0 ];then
|
||||||
@@ -32,8 +35,8 @@ while [ 1 ];do
|
|||||||
state="active"
|
state="active"
|
||||||
fi
|
fi
|
||||||
echo "$(date) INFO ${wavs} wav files waiting in ${ingest_dir}, $srv state is $state"
|
echo "$(date) INFO ${wavs} wav files waiting in ${ingest_dir}, $srv state is $state"
|
||||||
if [ $wavs -gt 100 -a $state = "active" ];then
|
if [ "$wavs" -gt 100 -a "$state" = "active" ];then
|
||||||
sudo systemctl stop $srv
|
sudo systemctl stop "$srv"
|
||||||
echo "$(date) WARNING stopped $srv service"
|
echo "$(date) WARNING stopped $srv service"
|
||||||
elif [ $wavs -le 100 -a $state = "inactive" ];then
|
elif [ $wavs -le 100 -a $state = "inactive" ];then
|
||||||
sudo systemctl start $srv
|
sudo systemctl start $srv
|
||||||
|
|||||||
Reference in New Issue
Block a user