From 11d26ffe105ca77fd35682988fa068e21a0a2737 Mon Sep 17 00:00:00 2001 From: riley Date: Thu, 21 Sep 2023 00:20:07 -0400 Subject: [PATCH] More config building refactors --- root/usr/libexec/apps/frigate/frigate.sh | 37 +++++++++++++++++------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/root/usr/libexec/apps/frigate/frigate.sh b/root/usr/libexec/apps/frigate/frigate.sh index a729750..190eb23 100755 --- a/root/usr/libexec/apps/frigate/frigate.sh +++ b/root/usr/libexec/apps/frigate/frigate.sh @@ -42,7 +42,7 @@ do_install_detail() { [ -z "$host" ] && { echo "Error: MQTT host not found in configuration."; exit 1; } echo "Fetching Coral status from configuration..." - coral=$(uci get frigate.tpu.enabled 2>/dev/null) + coral=$(uci get frigate.tpu.device 2>/dev/null) [ -z "$coral" ] && { echo "Error: Coral status not found in configuration."; exit 1; } echo "Fetching Coral type from configuration..." @@ -99,9 +99,9 @@ EOF echo "{}" > /opt/docker2/compose/frigate/config.yml # Set global configurations - yq eval ".usbcoral = \"$usbcoral\"" -i /opt/docker2/compose/frigate/config.yml - yq eval ".hwaccel = \"$hwaccel\"" -i /opt/docker2/compose/frigate/config.yml - yq eval ".storage = \"$storage\"" -i /opt/docker2/compose/frigate/config.yml + # yq eval ".usbcoral = \"$usbcoral\"" -i /opt/docker2/compose/frigate/config.yml + # yq eval ".hwaccel = \"$hwaccel\"" -i /opt/docker2/compose/frigate/config.yml + # yq eval ".media.storage = \"$storage\"" -i /opt/docker2/compose/frigate/config.yml yq eval ".mqtt.enabled = $mqtt" -i /opt/docker2/compose/frigate/config.yml yq eval ".mqtt.host = \"$host\"" -i /opt/docker2/compose/frigate/config.yml yq eval ".detectors.coral.type = \"$type\"" -i /opt/docker2/compose/frigate/config.yml @@ -114,7 +114,7 @@ EOF local camera_index=0 while : ; do # Try to fetch camera configuration - local name=$(uci get frigate.@camera_config[$camera_index].name 2>/dev/null) + local name=$(uci get frigate.@camera_config[$camera_index].name 2>/dev/null | tr ' ' '_') # Exit loop if no more cameras are found [[ -z "$name" ]] && break @@ -128,12 +128,27 @@ EOF # Initialize camera structure yq eval ".cameras.$name = {}" -i /opt/docker2/compose/frigate/config.yml - # Write to config.yml using yq - yq eval ".cameras.$name.ffmpeg = { inputs: [{ path: \"$path\", roles: [\"detect\"] }] }" -i /opt/docker2/compose/frigate/config.yml - yq eval ".cameras.$name.detect = { width: 1280, height: 720 }" -i /opt/docker2/compose/frigate/config.yml - yq eval ".cameras.$name.record = { enabled: $record }" -i /opt/docker2/compose/frigate/config.yml - yq eval ".cameras.$name.snapshots = { enabled: $snapshots }" -i /opt/docker2/compose/frigate/config.yml - yq eval ".cameras.$name.motion = { mask: [\"$mask\"] }" -i /opt/docker2/compose/frigate/config.yml + # Initialize ffmpeg and inputs for each camera + yq eval ".cameras.$name.ffmpeg = {}" -i /opt/docker2/compose/frigate/config.yml + yq eval ".cameras.$name.ffmpeg.inputs = []" -i /opt/docker2/compose/frigate/config.yml + + # Add path and roles to the inputs + yq eval ".cameras.$name.ffmpeg.inputs[0].path = \"\\\"$path\\\"\"" -i /opt/docker2/compose/frigate/config.yml + yq eval ".cameras.$name.ffmpeg.inputs[0].roles = [\"detect\"]" -i /opt/docker2/compose/frigate/config.yml + + # Add other camera settings + yq eval ".cameras.$name.detect = {}" -i /opt/docker2/compose/frigate/config.yml + yq eval ".cameras.$name.detect.width = 1280" -i /opt/docker2/compose/frigate/config.yml + yq eval ".cameras.$name.detect.height = 720" -i /opt/docker2/compose/frigate/config.yml + + yq eval ".cameras.$name.record = {}" -i /opt/docker2/compose/frigate/config.yml + yq eval ".cameras.$name.record.enabled = $record" -i /opt/docker2/compose/frigate/config.yml + + yq eval ".cameras.$name.snapshots = {}" -i /opt/docker2/compose/frigate/config.yml + yq eval ".cameras.$name.snapshots.enabled = $snapshots" -i /opt/docker2/compose/frigate/config.yml + + yq eval ".cameras.$name.motion = {}" -i /opt/docker2/compose/frigate/config.yml + yq eval ".cameras.$name.motion.mask = [\"$mask\"]" -i /opt/docker2/compose/frigate/config.yml camera_index=$((camera_index+1)) done