Fixed yq syntax

pull/3/head
riley 1 year ago
parent e07da23f19
commit cfeecbdf1f

@ -202,19 +202,28 @@ sync_camera_config() {
camera_index=$((camera_index+1)) camera_index=$((camera_index+1))
done done
# Then, handle deletions: # Then, handle deletions:
local cameras_in_yml=$(yq eval '.cameras | keys[]' /opt/docker2/compose/frigate/config.yml) local num_cameras=$(yq eval '.cameras | length' /opt/docker2/compose/frigate/config.yml 2>/dev/null)
echo "Checking for cameras in YML that are not in UCI..." local i=0
for camera_name in $cameras_in_yml; do local cameras_in_yml=""
echo "Validating camera: $camera_name in UCI"
if ! uci get frigate.@camera_config[*].name | grep -q "^$camera_name$"; then while [ "$i" -lt "$num_cameras" ]; do
echo "Camera $camera_name not found in UCI, removing from YML..." local camera_name=$(yq eval ".cameras | keys[$i]" /opt/docker2/compose/frigate/config.yml 2>/dev/null)
yq eval "del(.cameras.$camera_name)" -i /opt/docker2/compose/frigate/config.yml cameras_in_yml="$cameras_in_yml $camera_name"
echo "Removed $camera_name from YML" i=$((i+1))
else done
echo "Camera $camera_name found in UCI. No deletion needed."
fi echo "Checking for cameras in YML that are not in UCI..."
done for camera_name in $cameras_in_yml; do
echo "Validating camera: $camera_name in UCI"
if ! uci get frigate.@camera_config[*].name | grep -q "^$camera_name$"; then
echo "Camera $camera_name not found in UCI, removing from YML..."
yq eval "del(.cameras.$camera_name)" -i /opt/docker2/compose/frigate/config.yml
echo "Removed $camera_name from YML"
else
echo "Camera $camera_name found in UCI. No deletion needed."
fi
done
echo "sync_camera_config completed!" echo "sync_camera_config completed!"
} }

Loading…
Cancel
Save