|
|
|
@ -108,10 +108,6 @@ EOF
|
|
|
|
|
yq eval ".detectors.coral.type = \"$type\"" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
yq eval ".detectors.coral.device = \"$coral\"" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Initialize cameras structure
|
|
|
|
|
yq eval ".cameras = {}" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
|
|
# Write each camera's configuration to config.yml
|
|
|
|
|
local camera_index=0
|
|
|
|
|
while : ; do
|
|
|
|
@ -119,45 +115,7 @@ EOF
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
# Retrieve the rest of the camera settings here...
|
|
|
|
|
local path=$(uci get frigate.@camera_config[$camera_index].path 2>/dev/null)
|
|
|
|
|
local roles=$(uci get frigate.@camera_config[$camera_index].roles 2>/dev/null)
|
|
|
|
|
local record=$(uci get frigate.@camera_config[$camera_index].record 2>/dev/null)
|
|
|
|
|
local snapshots=$(uci get frigate.@camera_config[$camera_index].snapshots 2>/dev/null)
|
|
|
|
|
local mask=$(uci get frigate.@camera_config[$camera_index].mask 2>/dev/null)
|
|
|
|
|
|
|
|
|
|
# Initialize camera structure
|
|
|
|
|
yq eval ".cameras.$name = {}" -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
|
|
|
|
|
|
|
|
|
|
# Check if the mask is not empty
|
|
|
|
|
if [ -n "$mask" ]; then
|
|
|
|
|
# Run the yq commands to update the YAML file
|
|
|
|
|
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
|
|
|
|
|
else
|
|
|
|
|
echo "Mask is empty, ignoring."
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
write_camera_to_yml $name
|
|
|
|
|
camera_index=$((camera_index+1))
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
@ -320,7 +278,7 @@ update_camera_in_yml() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sync_camera_config() {
|
|
|
|
|
echo "Starting sync_camera_config..."
|
|
|
|
|
echo "Syncing camera config..."
|
|
|
|
|
|
|
|
|
|
# Initializing the camera index
|
|
|
|
|
camera_index=0
|
|
|
|
@ -339,10 +297,10 @@ sync_camera_config() {
|
|
|
|
|
[ -z "$camera_name" ] && break
|
|
|
|
|
|
|
|
|
|
if ! echo "$yml_cameras" | grep -q -w "$camera_name"; then
|
|
|
|
|
echo "Camera $camera_name not found in YML, adding..."
|
|
|
|
|
echo "UCI Camera $camera_name not found in YML, adding..."
|
|
|
|
|
write_camera_to_yml $camera_name
|
|
|
|
|
else
|
|
|
|
|
echo "Camera $camera_name found in YML, updating..."
|
|
|
|
|
echo "UCI Camera $camera_name found in YML, updating..."
|
|
|
|
|
update_camera_in_yml $camera_name
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|