mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-04 10:15:22 +03:00
37 lines
1.2 KiB
Plaintext
Executable File
37 lines
1.2 KiB
Plaintext
Executable File
#!/command/with-contenv bash
|
|
# shellcheck shell=bash
|
|
|
|
set -o errexit -o nounset -o pipefail
|
|
|
|
config_file="${CONFIG_FILE:-"/config/config.yml"}"
|
|
|
|
if [[ ! -f "${config_file}" ]]; then
|
|
config_file="${config_file//.yml/.yaml}"
|
|
if [[ ! -f "${config_file}" ]]; then
|
|
echo "[ERROR] Frigate config file not found" >&2
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
readonly config_file
|
|
|
|
# Use yq to check if database.path is set
|
|
user_db_path=$(yq eval '.database.path' "${config_file}")
|
|
readonly user_db_path
|
|
|
|
if [[ "${user_db_path}" == "null" ]]; then
|
|
readonly previous_db_path="/media/frigate/frigate.db"
|
|
readonly new_db_dir="/config"
|
|
if [[ -f "${previous_db_path}" ]]; then
|
|
if mountpoint --quiet "${new_db_dir}"; then
|
|
# /config is a mount point, move the db
|
|
echo "[INFO] Moving db from '${previous_db_path}' to the '${new_db_dir}' dir..." >&2
|
|
# Move all files that starts with frigate.db to the new directory
|
|
mv -vf "${previous_db_path}"* "${new_db_dir}"
|
|
else
|
|
echo "[ERROR] Trying to migrate the db path from '${previous_db_path}' to the '${new_db_dir}' dir, but '${new_db_dir}' is not a mountpoint, please mount the '${new_db_dir}' dir" >&2
|
|
exit 1
|
|
fi
|
|
fi
|
|
fi
|