Daemon services update
This commit is contained in:
parent
6b37e1cfc5
commit
2bedbac279
|
@ -28,9 +28,9 @@ mem() {
|
||||||
string=$2
|
string=$2
|
||||||
substring=$1
|
substring=$1
|
||||||
if [[ "$string" == *"$substring"* ]]; then
|
if [[ "$string" == *"$substring"* ]]; then
|
||||||
true
|
echo "true"
|
||||||
else
|
else
|
||||||
false
|
echo "false"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,11 +49,11 @@ junk() {
|
||||||
# Get all empty treatment directories
|
# Get all empty treatment directories
|
||||||
junk="$junk $(find ${CHUNK_FOLDER}/out -type d -empty)"
|
junk="$junk $(find ${CHUNK_FOLDER}/out -type d -empty)"
|
||||||
# Get all empty record directories
|
# Get all empty record directories
|
||||||
treatement_folder=$(find "${CHUNK_FOLDER}/out/*" -type d ! -empty)
|
treatement_folder=$(find -wholename "${CHUNK_FOLDER}/out/*" -type d ! -empty)
|
||||||
if [[ ! -z ${treatement_folder} ]]; then
|
if [[ ! -z ${treatement_folder} ]]; then
|
||||||
for folder in $treatement_folder; do
|
for folder in $treatement_folder; do
|
||||||
echo $folder
|
echo $folder
|
||||||
if ! $(mem $folder $junk) && $(no_bird_in_model_output $folder); then
|
if [[ ! $(mem $folder $junk) = "true" ]] && $(no_bird_in_model_output $folder); then
|
||||||
junk="$junk $folder"
|
junk="$junk $folder"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
|
@ -2,9 +2,10 @@
|
||||||
# Extract observations from a model output folder
|
# Extract observations from a model output folder
|
||||||
#
|
#
|
||||||
|
|
||||||
DEBUG=${DEBUG:-0}
|
DEBUG=${DEBUG:-1}
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
# set -x
|
||||||
|
|
||||||
debug() {
|
debug() {
|
||||||
if [ $DEBUG -eq 1 ]; then
|
if [ $DEBUG -eq 1 ]; then
|
||||||
|
@ -40,7 +41,7 @@ if [[ -z ${LONGITUDE} ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
model_outputs() {
|
model_outputs() {
|
||||||
find -name "model.out.csv" -type f ! -empty
|
ls ${CHUNK_FOLDER}/out/*/model.out.csv
|
||||||
}
|
}
|
||||||
|
|
||||||
source_wav() {
|
source_wav() {
|
||||||
|
@ -59,10 +60,10 @@ record_datetime() {
|
||||||
MM=$(echo $record_date | cut -c 5-6)
|
MM=$(echo $record_date | cut -c 5-6)
|
||||||
DD=$(echo $record_date | cut -c 7-8)
|
DD=$(echo $record_date | cut -c 7-8)
|
||||||
HH=$(echo $record_time | cut -c 1-2)
|
HH=$(echo $record_time | cut -c 1-2)
|
||||||
MM=$(echo $record_time | cut -c 3-4)
|
MI=$(echo $record_time | cut -c 3-4)
|
||||||
SS=$(echo $record_time | cut -c 5-6)
|
SS=$(echo $record_time | cut -c 5-6)
|
||||||
SSS="000"
|
SSS="000"
|
||||||
date="$YYYY-$MM-$DD $HH:$MM:$SS.$SSS"
|
date="$YYYY-$MM-$DD $HH:$MI:$SS.$SSS"
|
||||||
echo $date
|
echo $date
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,15 +103,15 @@ save_observations() {
|
||||||
debug "Observation already exists: $source_audio, $start, $end, $taxon_id, $location_id"
|
debug "Observation already exists: $source_audio, $start, $end, $taxon_id, $location_id"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
debug "Inserting observation: $source_audio, $start, $end, $taxon_id, $location_id"
|
debug "Inserting observation: $source_audio, $start, $end, $taxon_id, $location_id, $datetime"
|
||||||
insert_observation "$source_audio" "$start" "$end" "$taxon_id" "$location_id" "$confidence" "$datetime"
|
insert_observation "$source_audio" "$start" "$end" "$taxon_id" "$location_id" "$confidence" "$datetime"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
# Remove all junk observations
|
# # Remove all junk observations
|
||||||
./daemon/birdnet_clean.sh
|
# ./daemon/birdnet_clean.sh
|
||||||
# Get model outputs
|
# Get model outputs
|
||||||
for model_output in $(model_outputs); do
|
for model_output in $(model_outputs); do
|
||||||
save_observations $model_output
|
save_observations $model_output
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
Description=BirdNET-stream Analyzis
|
Description=BirdNET-stream Analyzis
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
User=$USER
|
User=<USER>
|
||||||
Group=$USER
|
Group=<USER>
|
||||||
WorkingDirectory=$DIR
|
WorkingDirectory=<DIR>
|
||||||
ExecStart=bash ./daemon/birdnet_analyzis.sh
|
ExecStart=bash ./daemon/birdnet_analyzis.sh
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=3
|
RestartSec=3
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
[Unit]
|
||||||
|
Description=BirdNET-stream miner service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
User=<USER>
|
||||||
|
GROUP=<GROUP>
|
||||||
|
WorkingDirectory=<DIR>
|
||||||
|
ExecStart=bash ./daemon/birdnet_miner.sh
|
||||||
|
RemainAfterExit=yes
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
|
@ -0,0 +1,9 @@
|
||||||
|
[Unit]
|
||||||
|
Description=BirdNET-stream miner Timer
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=*-*-* *:00
|
||||||
|
Unit=birdnet_miner.service
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=basic.target
|
|
@ -4,10 +4,10 @@
|
||||||
Description=BirdNET-stream recording
|
Description=BirdNET-stream recording
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
User=$USER
|
User=<USER>
|
||||||
Group=$DIR
|
Group=<DIR>
|
||||||
WorkingDirectory=$DIR
|
WorkingDirectory=<DIR>
|
||||||
ExecStart=bash ./daemon/birdnet_recording.sh"
|
ExecStart=bash ./daemon/birdnet_recording.sh
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=3
|
RestartSec=3
|
||||||
Type=simple
|
Type=simple
|
||||||
|
|
Loading…
Reference in New Issue