Enhance configuration handling and implement wizard completion logic
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-02-11 17:15:54 +11:00
parent e48a061ca0
commit c577d354e7
5 changed files with 69 additions and 2 deletions

View File

@@ -1,9 +1,68 @@
#!/bin/sh
set -eu
CONFIG_DIR="${XTEVE_CONFIG:-/xteve/config}"
DEFAULT_CONFIG_DIR="/xteve/config"
LEGACY_CONFIG_DIRS="/config /xteve /home/xteve/.xteve"
resolve_config_dir() {
if [ -n "${XTEVE_CONFIG:-}" ]; then
printf "%s" "${XTEVE_CONFIG}"
return
fi
for dir in ${LEGACY_CONFIG_DIRS}; do
if [ -f "${dir}/settings.json" ]; then
printf "%s" "${dir}"
return
fi
done
printf "%s" "${DEFAULT_CONFIG_DIR}"
}
copy_if_missing() {
src="$1"
dst="$2"
if [ -e "${src}" ] && [ ! -e "${dst}" ]; then
cp -R "${src}" "${dst}"
fi
}
CONFIG_DIR="$(resolve_config_dir)"
PORT="${XTEVE_PORT:-34400}"
mkdir -p "${CONFIG_DIR}"
if [ ! -f "${CONFIG_DIR}/settings.json" ]; then
for legacy_dir in ${LEGACY_CONFIG_DIRS}; do
if [ "${legacy_dir}" = "${CONFIG_DIR}" ]; then
continue
fi
if [ -f "${legacy_dir}/settings.json" ]; then
echo "[entrypoint] Migrating existing configuration from ${legacy_dir} to ${CONFIG_DIR}"
for file in authentication.json pms.json settings.json xepg.json urls.json; do
copy_if_missing "${legacy_dir}/${file}" "${CONFIG_DIR}/${file}"
done
for dir_name in data cache backup tmp; do
copy_if_missing "${legacy_dir}/${dir_name}" "${CONFIG_DIR}/${dir_name}"
done
break
fi
done
fi
if ! touch "${CONFIG_DIR}/.xteve-write-test" 2>/dev/null; then
echo "[entrypoint] ERROR: Config directory is not writable: ${CONFIG_DIR}" >&2
ls -ld "${CONFIG_DIR}" >&2 || true
exit 1
fi
rm -f "${CONFIG_DIR}/.xteve-write-test"
echo "[entrypoint] Using config directory: ${CONFIG_DIR}"
exec /usr/local/bin/xteve -config "${CONFIG_DIR}" -port "${PORT}" "$@"