HA Addon: fix config file check in entrypoint (#24972)

This commit is contained in:
thecem 2025-11-02 12:17:18 +01:00 • committed by GitHub
parent 2f48158655
commit 5f14c02077
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5,12 +5,12 @@ set -e
HASSIO_OPTIONSFILE=/data/options.json
if [ -f ${HASSIO_OPTIONSFILE} ]; then
CONFIG=$(grep -o '"config_file": "[^"]*' ${HASSIO_OPTIONSFILE} | grep -o '[^"]*$')
SQLITE_FILE=$(grep -o '"sqlite_file": "[^"]*' ${HASSIO_OPTIONSFILE} | grep -o '[^"]*$')
CONFIG=$(grep -o '"config_file": "[^"]*' ${HASSIO_OPTIONSFILE} | grep -o '[^"]*$' || true)
SQLITE_FILE=$(grep -o '"sqlite_file": "[^"]*' ${HASSIO_OPTIONSFILE} | grep -o '[^"]*$' || true)
# Config File Migration
# If there is no config file found in '/config' we copy it from '/homeassistant' and rename the old config file to .migrated
if [ ! -f "${CONFIG}" ]; then
if [ -n "${CONFIG}" ] && [ ! -f "${CONFIG}" ]; then
CONFIG_OLD=$(echo "${CONFIG}" | sed 's#^/config#/homeassistant#')
if [ -f "${CONFIG_OLD}" ]; then
mkdir -p "$(dirname "${CONFIG}")" && cp "${CONFIG_OLD}" "${CONFIG}"