Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hassio: preparation to enable us to change home assistant addon, details: https://github.com/evcc-io/hassio-addon/issues/75 #18730

Merged
merged 1 commit into from
Feb 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions packaging/docker/bin/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,31 @@ HASSIO_OPTIONSFILE=/data/options.json

if [ -f ${HASSIO_OPTIONSFILE} ]; then
CONFIG=$(grep -o '"config_file": "[^"]*' ${HASSIO_OPTIONSFILE} | grep -o '[^"]*$')
echo "Using config file: ${CONFIG}"

SQLITE_FILE=$(grep -o '"sqlite_file": "[^"]*' ${HASSIO_OPTIONSFILE} | grep -o '[^"]*$')

# 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
CONFIG_OLD=$(echo "${CONFIG}" | sed 's#^/config#/homeassistant#')
if [ -f "${CONFIG_OLD}" ]; then
mkdir -p "$(dirname "${CONFIG}")" && cp "${CONFIG_OLD}" "${CONFIG}"
mv "${CONFIG_OLD}" "${CONFIG_OLD}.migrated"
echo "Moving old config file '${CONFIG_OLD}' to new location '${CONFIG}', appending '.migrated' to old config file! Old file can safely be deleted by user."
fi
fi

# Database File Migration (optional, in case it is in /config)
# Only in case the user put her DB into the '/config' folder instead of default '/data' we will migrate it aswell
if [ "${SQLITE_FILE#/config}" != "${SQLITE_FILE}" ] && [ ! -f "${SQLITE_FILE}" ]; then
SQLITE_FILE_OLD=$(echo "${SQLITE_FILE}" | sed 's#^/config#/homeassistant#')
if [ -f "${SQLITE_FILE_OLD}" ]; then
mkdir -p "$(dirname "${SQLITE_FILE}")" && cp "${SQLITE_FILE_OLD}" "${SQLITE_FILE}"
mv "${SQLITE_FILE_OLD}" "${SQLITE_FILE_OLD}.migrated"
echo "Moving old db file '${SQLITE_FILE_OLD}' to new location '${SQLITE_FILE}', appending '.migrated' to old db file! Old file can safely be deleted by user."
fi
fi

echo "Using config file: ${CONFIG}"
if [ ! -f "${CONFIG}" ]; then
echo "Config not found. Please create a config under ${CONFIG}."
echo "For details see evcc documentation at https://github.com/evcc-io/evcc#readme."
Expand Down
Loading