|
|
|
@ -174,6 +174,51 @@ usage() {
|
|
|
|
|
echo " port frigate port"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sync_camera_config() {
|
|
|
|
|
echo "Starting sync_camera_config..."
|
|
|
|
|
|
|
|
|
|
# First, handle additions:
|
|
|
|
|
local camera_index=0
|
|
|
|
|
while : ; do
|
|
|
|
|
local name=$(uci get frigate.@camera_config[$camera_index].name 2>/dev/null | tr ' ' '_')
|
|
|
|
|
if [[ -z "$name" ]]; then
|
|
|
|
|
echo "No more cameras found in UCI at index $camera_index. Moving to deletions..."
|
|
|
|
|
break
|
|
|
|
|
fi
|
|
|
|
|
echo "Processing UCI camera named: $name"
|
|
|
|
|
|
|
|
|
|
# Check if the camera is in the YML
|
|
|
|
|
if ! yq eval "has(.cameras.$name)" /opt/docker2/compose/frigate/config.yml; then
|
|
|
|
|
echo "Camera $name not found in YML, adding..."
|
|
|
|
|
|
|
|
|
|
# Initialize camera structure in YML
|
|
|
|
|
yq eval ".cameras.$name = {}" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
echo "Initialized $name in YML"
|
|
|
|
|
# ... Add other camera configurations here as needed ...
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
echo "Camera $name already exists in YML. Skipping addition."
|
|
|
|
|
fi
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
echo "sync_camera_config completed!"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case "${ACTION}" in
|
|
|
|
|
"install" | "upgrade")
|
|
|
|
|