More config building refactors

pull/2/head
riley 1 year ago
parent 9892b62ca2
commit 11d26ffe10

@ -42,7 +42,7 @@ do_install_detail() {
[ -z "$host" ] && { echo "Error: MQTT host not found in configuration."; exit 1; } [ -z "$host" ] && { echo "Error: MQTT host not found in configuration."; exit 1; }
echo "Fetching Coral status from configuration..." 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; } [ -z "$coral" ] && { echo "Error: Coral status not found in configuration."; exit 1; }
echo "Fetching Coral type from configuration..." echo "Fetching Coral type from configuration..."
@ -99,9 +99,9 @@ EOF
echo "{}" > /opt/docker2/compose/frigate/config.yml echo "{}" > /opt/docker2/compose/frigate/config.yml
# Set global configurations # Set global configurations
yq eval ".usbcoral = \"$usbcoral\"" -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 ".hwaccel = \"$hwaccel\"" -i /opt/docker2/compose/frigate/config.yml
yq eval ".storage = \"$storage\"" -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.enabled = $mqtt" -i /opt/docker2/compose/frigate/config.yml
yq eval ".mqtt.host = \"$host\"" -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 yq eval ".detectors.coral.type = \"$type\"" -i /opt/docker2/compose/frigate/config.yml
@ -114,7 +114,7 @@ EOF
local camera_index=0 local camera_index=0
while : ; do while : ; do
# Try to fetch camera configuration # 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 # Exit loop if no more cameras are found
[[ -z "$name" ]] && break [[ -z "$name" ]] && break
@ -128,12 +128,27 @@ EOF
# Initialize camera structure # Initialize camera structure
yq eval ".cameras.$name = {}" -i /opt/docker2/compose/frigate/config.yml yq eval ".cameras.$name = {}" -i /opt/docker2/compose/frigate/config.yml
# Write to config.yml using yq # Initialize ffmpeg and inputs for each camera
yq eval ".cameras.$name.ffmpeg = { inputs: [{ path: \"$path\", roles: [\"detect\"] }] }" -i /opt/docker2/compose/frigate/config.yml yq eval ".cameras.$name.ffmpeg = {}" -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.ffmpeg.inputs = []" -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 # Add path and roles to the inputs
yq eval ".cameras.$name.motion = { mask: [\"$mask\"] }" -i /opt/docker2/compose/frigate/config.yml 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)) camera_index=$((camera_index+1))
done done

Loading…
Cancel
Save