From c577d354e7b44b8ba396698abee3f65ff083e2ba Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Wed, 11 Feb 2026 17:15:54 +1100 Subject: [PATCH] Enhance configuration handling and implement wizard completion logic --- docker/entrypoint.sh | 61 +++++++++++++++++++++++++++++++++++++++++++- src/data.go | 4 +++ src/struct-system.go | 1 + src/system.go | 3 +++ src/webserver.go | 2 +- 5 files changed, 69 insertions(+), 2 deletions(-) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index b87d94c..843343a 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -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}" "$@" diff --git a/src/data.go b/src/data.go index bcf6a6b..1cada9b 100644 --- a/src/data.go +++ b/src/data.go @@ -761,6 +761,10 @@ func saveWizard(request RequestStruct) (nextStep int, err error) { } + if nextStep == 10 { + Settings.WizardCompleted = true + } + err = saveSettings(Settings) if err != nil { return diff --git a/src/struct-system.go b/src/struct-system.go index da888c6..5295e21 100644 --- a/src/struct-system.go +++ b/src/struct-system.go @@ -302,6 +302,7 @@ type SettingsStruct struct { Version string `json:"version"` XepgReplaceMissingImages bool `json:"xepg.replace.missing.images"` XteveAutoUpdate bool `json:"xteveAutoUpdate"` + WizardCompleted bool `json:"wizard.completed"` } // LanguageUI : Sprache für das WebUI diff --git a/src/system.go b/src/system.go index 7a91970..be4a732 100644 --- a/src/system.go +++ b/src/system.go @@ -97,6 +97,8 @@ func loadSettings() (settings SettingsStruct, err error) { return } + var freshInstall = len(settingsMap) == 0 + // Deafult Werte setzten var defaults = make(map[string]any) var dataMap = make(map[string]any) @@ -150,6 +152,7 @@ func loadSettings() (settings SettingsStruct, err error) { defaults["udpxy"] = "" defaults["version"] = System.DBVersion defaults["xteveAutoUpdate"] = true + defaults["wizard.completed"] = !freshInstall var defaultTempPath = System.Folder.Temp if len(os.Getenv("XTEVE_CONFIG")) > 0 { defaultTempPath = System.Folder.Config + "tmp" + string(os.PathSeparator) diff --git a/src/webserver.go b/src/webserver.go index 0a52ef2..cfa81a3 100644 --- a/src/webserver.go +++ b/src/webserver.go @@ -637,7 +637,7 @@ func Web(w http.ResponseWriter, r *http.Request) { if System.ScanInProgress == 0 { - if len(Settings.Files.M3U) == 0 && len(Settings.Files.HDHR) == 0 { + if Settings.WizardCompleted == false && len(Settings.Files.M3U) == 0 && len(Settings.Files.HDHR) == 0 { System.ConfigurationWizard = true }