Align bash and python scripts to prefer config.yml over config.yaml

This commit is contained in:
Felipe Santos 2025-03-23 13:27:56 -03:00
parent a0c8cc9562
commit 4ee9a44948
4 changed files with 19 additions and 28 deletions

View File

@ -24,10 +24,11 @@ function migrate_addon_config_dir() {
local old_config_file="${home_assistant_config_dir}/frigate.yml"
local old_config_file_yaml="${old_config_file//.yml/.yaml}"
local new_config_file="${config_dir}/config.yml"
if [[ -f "${old_config_file_yaml}" ]]; then
if [[ -f "${old_config_file}" ]]; then
:
elif [[ -f "${old_config_file_yaml}" ]]; then
old_config_file="${old_config_file_yaml}"
new_config_file="${new_config_file//.yml/.yaml}"
elif [[ ! -f "${old_config_file}" ]]; then
else
# Nothing to migrate
return 0
fi
@ -103,12 +104,14 @@ function migrate_addon_config_dir() {
}
function migrate_db_from_media_to_config() {
# Find config file in yaml or yml, but prefer yaml
# Find config file in yml or yaml, but prefer yml
local config_file="${CONFIG_FILE:-"/config/config.yml"}"
local config_file_yaml="${config_file//.yml/.yaml}"
if [[ -f "${config_file_yaml}" ]]; then
if [[ -f "${config_file}" ]]; then
:
elif [[ -f "${config_file_yaml}" ]]; then
config_file="${config_file_yaml}"
elif [[ ! -f "${config_file}" ]]; then
else
# Frigate will create the config file on startup
return 0
fi

View File

@ -1,5 +1,4 @@
import json
import os
import sys
from ruamel.yaml import YAML
@ -9,17 +8,12 @@ from frigate.const import (
DEFAULT_FFMPEG_VERSION,
INCLUDED_FFMPEG_VERSIONS,
)
from frigate.util.config import find_config_file
sys.path.remove("/opt/frigate")
yaml = YAML()
config_file = os.environ.get("CONFIG_FILE", "/config/config.yml")
# Check if we can use .yaml instead of .yml
config_file_yaml = config_file.replace(".yml", ".yaml")
if os.path.isfile(config_file_yaml):
config_file = config_file_yaml
config_file = find_config_file()
try:
with open(config_file) as f:

View File

@ -15,7 +15,7 @@ from frigate.const import (
LIBAVFORMAT_VERSION_MAJOR,
)
from frigate.ffmpeg_presets import parse_preset_hardware_acceleration_encode
from frigate.util.config import find_config_file
sys.path.remove("/opt/frigate")
yaml = YAML()
@ -29,12 +29,7 @@ if os.path.isdir("/run/secrets"):
Path(os.path.join("/run/secrets", secret_file)).read_text().strip()
)
config_file = os.environ.get("CONFIG_FILE", "/config/config.yml")
# Check if we can use .yaml instead of .yml
config_file_yaml = config_file.replace(".yml", ".yaml")
if os.path.isfile(config_file_yaml):
config_file = config_file_yaml
config_file = find_config_file()
try:
with open(config_file) as f:

View File

@ -1,18 +1,17 @@
"""Prints the tls config as json to stdout."""
import json
import os
import sys
from ruamel.yaml import YAML
sys.path.insert(0, "/opt/frigate")
from frigate.util.config import find_config_file
sys.path.remove("/opt/frigate")
yaml = YAML()
config_file = os.environ.get("CONFIG_FILE", "/config/config.yml")
# Check if we can use .yaml instead of .yml
config_file_yaml = config_file.replace(".yml", ".yaml")
if os.path.isfile(config_file_yaml):
config_file = config_file_yaml
config_file = find_config_file()
try:
with open(config_file) as f: