Removed YML helper functions, they are more trouble then they are worth

pull/3/head
riley 12 months ago
parent 8eb3ddbea8
commit 71ba2606a7

@ -156,32 +156,6 @@ set_uci_camera_value() {
uci commit frigate
}
# YML Helper Functions
# Retrieves a specific setting from the YML. If no setting_path is provided, it retrieves the camera name.
get_yml_value() {
local name=$1
local setting_path=${2:-}
yq eval ".cameras.$name$setting_path" /opt/docker2/compose/frigate/config.yml
}
# Sets a specific setting in the YML
set_yml_value() {
local name=$1
local setting_path=$2
local value=$3
# If the value starts with "{", "[", or is a number, we don't quote it; otherwise, we do.
case "$value" in
"{"*|"["*|*[0-9]*)
# do nothing
;;
*)
value="\"$value\""
;;
esac
yq eval ".cameras.$name$setting_path = $value" -i /opt/docker2/compose/frigate/config.yml
}
write_camera_to_yml() {
local name=$1
local camera_index=""
@ -291,29 +265,29 @@ update_camera_in_yml() {
# For each attribute you update, apply warning comment
local path=$(get_uci_camera_value $camera_index "path")
set_yml_value $name ".ffmpeg.inputs[0].path" "\"$path\""
yq eval '.cameras.'$name'.ffmpeg.inputs[0].path = "'$path'"' -i /opt/docker2/compose/frigate/config.yml
overwrite_warning_comment $name "ffmpeg.inputs[0].path"
local roles=$(get_uci_camera_value $camera_index "roles")
set_yml_value $name ".ffmpeg.inputs[0].roles" $roles
local roles="[\"detect\"]" # adjust as necessary
yq eval '.cameras.'$name'.ffmpeg.inputs[0].roles = '$roles'' -i /opt/docker2/compose/frigate/config.yml
overwrite_warning_comment $name "ffmpeg.inputs[0].roles"
local record=$(get_uci_camera_value $camera_index "record")
set_yml_value $name ".record.enabled" $record
yq eval '.cameras.'$name'.record.enabled = '$record'' -i /opt/docker2/compose/frigate/config.yml
overwrite_warning_comment $name "record.enabled"
local snapshots=$(get_uci_camera_value $camera_index "snapshots")
set_yml_value $name ".snapshots.enabled" $snapshots
yq eval '.cameras.'$name'.snapshots.enabled = '$snapshots'' -i /opt/docker2/compose/frigate/config.yml
overwrite_warning_comment $name "snapshots.enabled"
local mask=$(get_uci_camera_value $camera_index "mask")
if [ -n "$mask" ]; then
set_yml_value $name ".motion.mask" "[\"$mask\"]"
yq eval '.cameras.'$name'.motion.mask = ["'$mask'"]' -i /opt/docker2/compose/frigate/config.yml
overwrite_warning_comment $name "motion.mask"
else
yq eval "del(.cameras.$name.motion)" -i /opt/docker2/compose/frigate/config.yml
fi
yq eval '(.cameras.Office | key) line_comment="DO NOT REMOVE - Managed by PrivateRouter Script"' -i /opt/docker2/compose/frigate/config.yml
yq eval '(.cameras.'$name' | key) line_comment="DO NOT REMOVE - Managed by PrivateRouter Script"' -i /opt/docker2/compose/frigate/config.yml
}
sync_camera_config() {

Loading…
Cancel
Save