mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-07-30 13:48:07 +02:00
Migrate all files I know
This commit is contained in:
parent
f94b5f1322
commit
06f1317a74
@ -5,12 +5,15 @@
|
||||
set -o errexit -o nounset -o pipefail
|
||||
|
||||
function migrate_addon_config_dir() {
|
||||
if ! mountpoint --quiet /homeassistant; then
|
||||
local home_assistant_config_dir="/homeassistant"
|
||||
|
||||
if ! mountpoint --quiet "${home_assistant_config_dir}"; then
|
||||
# Not running as a Home Assistant add-on
|
||||
return 0
|
||||
fi
|
||||
|
||||
local new_config_file="/config/config.yml"
|
||||
local config_dir="/config"
|
||||
local new_config_file="${config_dir}/config.yml"
|
||||
local new_config_file_yaml="${new_config_file//.yml/.yaml}"
|
||||
if [[ -f "${new_config_file_yaml}" || -f "${new_config_file}" ]]; then
|
||||
# Already migrated
|
||||
@ -18,12 +21,12 @@ function migrate_addon_config_dir() {
|
||||
fi
|
||||
unset new_config_file new_config_file_yaml
|
||||
|
||||
local old_config_file="/homeassistant/frigate.yml"
|
||||
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/config.yml"
|
||||
local new_config_file="${config_dir}/config.yml"
|
||||
if [[ -f "${old_config_file_yaml}" ]]; then
|
||||
old_config_file="${old_config_file_yaml}"
|
||||
new_config_file="/config/config.yaml"
|
||||
new_config_file="${new_config_file//.yml/.yaml}"
|
||||
elif [[ ! -f "${old_config_file}" ]]; then
|
||||
# Nothing to migrate
|
||||
return 0
|
||||
@ -33,11 +36,11 @@ function migrate_addon_config_dir() {
|
||||
local db_path
|
||||
db_path=$(yq eval '.database.path' "${old_config_file}")
|
||||
if [[ "${db_path}" == "null" ]]; then
|
||||
db_path="/config/frigate.db"
|
||||
db_path="${config_dir}/frigate.db"
|
||||
fi
|
||||
if [[ "${db_path}" == /config/* ]]; then
|
||||
# replace /config/ prefix with /homeassistant/
|
||||
local old_db_path="/homeassistant/${db_path:8}"
|
||||
local old_db_path="${home_assistant_config_dir}/${db_path:8}"
|
||||
|
||||
if [[ -f "${old_db_path}" ]]; then
|
||||
local new_db_dir
|
||||
@ -52,7 +55,7 @@ function migrate_addon_config_dir() {
|
||||
model_path=$(yq eval '.model.path' "${old_config_file}")
|
||||
if [[ "${model_path}" == /config/* ]]; then
|
||||
# replace /config/ prefix with /homeassistant/
|
||||
local old_model_path="/homeassistant/${model_path:8}"
|
||||
local old_model_path="${home_assistant_config_dir}/${model_path:8}"
|
||||
|
||||
if [[ -f "${old_model_path}" ]]; then
|
||||
local new_model_dir
|
||||
@ -63,8 +66,23 @@ function migrate_addon_config_dir() {
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "[INFO] Migrating miscellaneous files '${home_assistant_config_dir}' to '${config_dir}'..."
|
||||
local file
|
||||
for file in .exports .jwt_secret .timeline .vacuum go2rtc; do
|
||||
if [[ -f "${home_assistant_config_dir}/${file}" ]]; then
|
||||
mv -vf "${home_assistant_config_dir}/${file}" "${config_dir}"
|
||||
fi
|
||||
done
|
||||
file="${home_assistant_config_dir}/model_cache"
|
||||
if [[ -d "${file}" ]]; then
|
||||
echo "[INFO] Migrating '${file}' to '${config_dir}'..."
|
||||
mv -f "${file}" "${config_dir}"
|
||||
fi
|
||||
|
||||
echo "[INFO] Migrating config from '${old_config_file}' to '${new_config_file}'..."
|
||||
mv -vf "${old_config_file}" "${new_config_file}"
|
||||
|
||||
echo "[INFO] Migration from Home Assistant config dir to add-on config dir completed."
|
||||
}
|
||||
|
||||
function migrate_db_from_media_to_config() {
|
||||
|
Loading…
Reference in New Issue
Block a user