diff --git a/root/usr/libexec/apps/frigate/frigate.sh b/root/usr/libexec/apps/frigate/frigate.sh index 0d3886f..7d941f0 100755 --- a/root/usr/libexec/apps/frigate/frigate.sh +++ b/root/usr/libexec/apps/frigate/frigate.sh @@ -250,6 +250,21 @@ get_camera_index_by_name() { done } +# Toggles the line comment for a specific camera attribute in the YML +toggle_override() { + local name=$1 + local attribute=$2 + local current_comment=$(yq eval ".cameras.$name.$attribute | line_comment" /opt/docker2/compose/frigate/config.yml) + + if [ "$current_comment" = "OVERWRITTEN_BY_UCI" ]; then + # If the current comment is "OVERWRITTEN_BY_UCI", remove it by setting it to nothing + yq eval ".cameras.$name.$attribute line_comment=\"\"" -i /opt/docker2/compose/frigate/config.yml + else + # Otherwise, set the comment to "OVERWRITTEN_BY_UCI" + yq eval ".cameras.$name.$attribute line_comment=\"OVERWRITTEN_BY_UCI\"" -i /opt/docker2/compose/frigate/config.yml + fi +} + update_camera_in_yml() { local name=$1