From a685ff6add6e973b329861de3f1f8efdfb0c1bbc Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 15 May 2025 10:26:31 +0200 Subject: [PATCH] Update 01-structure.sh --- .../rootfs/etc/cont-init.d/01-structure.sh | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/birdnet-go/rootfs/etc/cont-init.d/01-structure.sh b/birdnet-go/rootfs/etc/cont-init.d/01-structure.sh index 8b73ba923..0f95dce42 100755 --- a/birdnet-go/rootfs/etc/cont-init.d/01-structure.sh +++ b/birdnet-go/rootfs/etc/cont-init.d/01-structure.sh @@ -4,7 +4,7 @@ set -e # Default Variables DEFAULT_BIRDSONGS_FOLDER="/data/clips/" -CONFIG_LOCATIONS=("/config/config.yaml") +CONFIG_LOCATION="/config/config.yaml" if [ ! -f /config/config.yaml ]; then bashio::log.warning "There is no config.yaml yet in the config folder, downloading a default one. Please customize" @@ -24,12 +24,7 @@ fi ###################### CURRENT_BIRDSONGS_FOLDER="clips/" # Read the current folder from config files -for configloc in "${CONFIG_LOCATIONS[@]}"; do - if [ -f "$configloc" ]; then - CURRENT_BIRDSONGS_FOLDER="$(yq '.realtime.audio.export.path' "$configloc" | tr -d '\"')" - break - fi -done +CURRENT_BIRDSONGS_FOLDER="$(yq '.realtime.audio.export.path' "$CONFIG_LOCATION" | tr -d '\"')" CURRENT_BIRDSONGS_FOLDER="${CURRENT_BIRDSONGS_FOLDER:-$DEFAULT_BIRDSONGS_FOLDER}" # Adjust default path if it matches the default string @@ -60,11 +55,7 @@ bashio::log.info "... audio clips saved to $BIRDSONGS_FOLDER according to addon if [[ "${CURRENT_BIRDSONGS_FOLDER%/}" != "${BIRDSONGS_FOLDER%/}" ]]; then bashio::log.warning "Birdsongs folder changed from $CURRENT_BIRDSONGS_FOLDER to $BIRDSONGS_FOLDER" # Update config files with the new birdsongs folder path - for configloc in "${CONFIG_LOCATIONS[@]}"; do - if [ -f "$configloc" ]; then - yq -i -y ".realtime.audio.export.path = \"$BIRDSONGS_FOLDER/\"" "$configloc" - fi - done + yq -i -y ".realtime.audio.export.path = \"$BIRDSONGS_FOLDER/\"" "$CONFIG_LOCATION" # Move files only if sqlite paths changed if [[ -d "$CURRENT_BIRDSONGS_FOLDER" && "$(ls -A "$CURRENT_BIRDSONGS_FOLDER")" ]]; then bashio::log.warning "Migrating files from $CURRENT_BIRDSONGS_FOLDER to $BIRDSONGS_FOLDER" @@ -107,16 +98,12 @@ fi bashio::log.info "Correcting configuration for defaults" # Update database location in config files -for configloc in "${CONFIG_LOCATIONS[@]}"; do - if [ -f "$configloc" ]; then - yq -i -y ".output.sqlite.path = \"/config/birdnet.db\"" "$configloc" - bashio::log.info "... database is located in $configloc" - fi -done +yq -i -y ".output.sqlite.path = \"/config/birdnet.db\"" "$CONFIG_LOCATION" +bashio::log.info "... database is located in /config/birdnet.db" # Adjust microphone volume if needed -current_volume="$(amixer sget Capture | grep -oP '\[\d+%\]' | tr -d '[]%' | head -1 2>/dev/null || echo "100")" +current_volume="$(amixer sget Capture | grep -oP '\[\d+%\]' | tr -d '[]%' | head -1 2>/dev/null || echo "100")" || true if [[ "$current_volume" -eq 0 ]]; then amixer sset Capture 70% bashio::log.warning "Microphone was off, volume set to 70%." -fi +fi || true