Enhance configuration handling and implement wizard completion logic
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,9 +1,68 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
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}"
|
PORT="${XTEVE_PORT:-34400}"
|
||||||
|
|
||||||
mkdir -p "${CONFIG_DIR}"
|
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}" "$@"
|
exec /usr/local/bin/xteve -config "${CONFIG_DIR}" -port "${PORT}" "$@"
|
||||||
|
|||||||
@@ -761,6 +761,10 @@ func saveWizard(request RequestStruct) (nextStep int, err error) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if nextStep == 10 {
|
||||||
|
Settings.WizardCompleted = true
|
||||||
|
}
|
||||||
|
|
||||||
err = saveSettings(Settings)
|
err = saveSettings(Settings)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -302,6 +302,7 @@ type SettingsStruct struct {
|
|||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
XepgReplaceMissingImages bool `json:"xepg.replace.missing.images"`
|
XepgReplaceMissingImages bool `json:"xepg.replace.missing.images"`
|
||||||
XteveAutoUpdate bool `json:"xteveAutoUpdate"`
|
XteveAutoUpdate bool `json:"xteveAutoUpdate"`
|
||||||
|
WizardCompleted bool `json:"wizard.completed"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// LanguageUI : Sprache für das WebUI
|
// LanguageUI : Sprache für das WebUI
|
||||||
|
|||||||
@@ -97,6 +97,8 @@ func loadSettings() (settings SettingsStruct, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var freshInstall = len(settingsMap) == 0
|
||||||
|
|
||||||
// Deafult Werte setzten
|
// Deafult Werte setzten
|
||||||
var defaults = make(map[string]any)
|
var defaults = make(map[string]any)
|
||||||
var dataMap = make(map[string]any)
|
var dataMap = make(map[string]any)
|
||||||
@@ -150,6 +152,7 @@ func loadSettings() (settings SettingsStruct, err error) {
|
|||||||
defaults["udpxy"] = ""
|
defaults["udpxy"] = ""
|
||||||
defaults["version"] = System.DBVersion
|
defaults["version"] = System.DBVersion
|
||||||
defaults["xteveAutoUpdate"] = true
|
defaults["xteveAutoUpdate"] = true
|
||||||
|
defaults["wizard.completed"] = !freshInstall
|
||||||
var defaultTempPath = System.Folder.Temp
|
var defaultTempPath = System.Folder.Temp
|
||||||
if len(os.Getenv("XTEVE_CONFIG")) > 0 {
|
if len(os.Getenv("XTEVE_CONFIG")) > 0 {
|
||||||
defaultTempPath = System.Folder.Config + "tmp" + string(os.PathSeparator)
|
defaultTempPath = System.Folder.Config + "tmp" + string(os.PathSeparator)
|
||||||
|
|||||||
@@ -637,7 +637,7 @@ func Web(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
if System.ScanInProgress == 0 {
|
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
|
System.ConfigurationWizard = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user