|
|
|
@ -202,19 +202,28 @@ sync_camera_config() {
|
|
|
|
|
camera_index=$((camera_index+1))
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# Then, handle deletions:
|
|
|
|
|
local cameras_in_yml=$(yq eval '.cameras | keys[]' /opt/docker2/compose/frigate/config.yml)
|
|
|
|
|
echo "Checking for cameras in YML that are not in UCI..."
|
|
|
|
|
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
|
|
|
|
|
# Then, handle deletions:
|
|
|
|
|
local num_cameras=$(yq eval '.cameras | length' /opt/docker2/compose/frigate/config.yml 2>/dev/null)
|
|
|
|
|
local i=0
|
|
|
|
|
local cameras_in_yml=""
|
|
|
|
|
|
|
|
|
|
while [ "$i" -lt "$num_cameras" ]; do
|
|
|
|
|
local camera_name=$(yq eval ".cameras | keys[$i]" /opt/docker2/compose/frigate/config.yml 2>/dev/null)
|
|
|
|
|
cameras_in_yml="$cameras_in_yml $camera_name"
|
|
|
|
|
i=$((i+1))
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
echo "Checking for cameras in YML that are not in UCI..."
|
|
|
|
|
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!"
|
|
|
|
|
}
|
|
|
|
|