librelad 7c28007779 refactor(config): updater knobs -> configs/webui/webui_updater; fix config heal/reconcile gaps
Move the WebUI-updater settings out of general_terminal into their own
advanced webui-category file (webui_logs precedent): new
configs/webui/webui_updater holds CFG_UPDATER_SCAN_INTERVAL and the
migrated CFG_HOTFIX_AUTO, listed in webui/.category.

The move only reaches existing installs if the config convergence
machinery works, and three pieces of it silently didn't:

- checkConfigFilesMissingFiles walked a stale hardcoded category list
  ('general features network' — features doesn't exist; webui/backup/
  security never healed). Derive the categories from the template tree
  instead, and heal .category metadata too: copy it when absent and
  merge missing SUBCATEGORY_ORDER entries when present, so healed files
  actually appear in the WebUI Config editor. core_categories removed.
- Option reconciliation never touched ANY nested config file: configs_dir
  carries a trailing slash, so rel stripping missed ('configs//'), the
  template lookup failed, and reconcileConfigFile early-returned for
  every file. Strip the slash before matching.
- reconcileConfigFile's AUTO_DELETE=false branch read a never-populated
  live_line array, losing the dropped keys it promised to keep. Populate
  it alongside live_value.

Also exclude *.bak from config sourcing (reconciliation writes <file>.bak
next to live configs — now that it runs, sourcing backups would resurrect
deleted keys), and add 'libreportal config check' as a non-interactive
front door to the converge pass (was only reachable via install flows and
the interactive menu).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: librelad <librelad@digitalangels.vip>
2026-06-12 22:33:23 +01:00

74 lines
2.9 KiB
Bash
Executable File

#!/bin/bash
sourceScanFiles()
{
local load_type="$1"
local file_pattern
# Specific LibrePortal config files
if [ "$load_type" = "libreportal_configs" ]; then
# Load new subdirectory config files only (no more old structure fallback)
local folder_dir="$configs_dir"
# Load new subdirectory config files with exclusions
while IFS= read -r -d '' file; do
if [ -f "$file" ]; then
local filename=$(basename "$file")
local should_load=true
# Skip .category files and excluded files
if [[ "$file" =~ \.category$ ]] || [[ "$filename" == "app_categories" ]]; then
should_load=false
fi
if [ "$should_load" = true ]; then
source "$file"
# echo "$load_type NEW FILE $file"
fi
fi
done < <(find "$folder_dir" -maxdepth 2 -type f ! -name "*.category" ! -name "config_*" ! -name ".*" ! -name "*.bak" -print0)
# Per-location backup configs live nested at depth 3
# (configs/backup/locations/<idx>/location.config) — source them via
# the dedicated loader so CFG_BACKUP_LOC_<idx>_* vars are populated.
if declare -f sourceBackupLocations >/dev/null 2>&1; then
sourceBackupLocations
fi
# Specific for LibrePortal app container configs
elif [ "$load_type" = "app_configs" ]; then
local file_pattern="*.config"
local folder_dir="$containers_dir"
# Specific for LibrePortal app install scripts
elif [ "$load_type" = "containers" ]; then
local file_pattern="*.sh"
local folder_dir="$install_containers_dir"
else
echo "Invalid load type: $load_type"
fi
# Scanning function for other types (not libreportal_configs).
# app_configs live under /docker/containers (owned by the docker install user
# and not list-readable by the manager), so enumerate them AS that user via
# runFileOp; the manager still sources each (the .config files are o+r). The
# 'containers' install templates are manager-owned, so a plain find suffices.
if [ "$load_type" != "libreportal_configs" ]; then
local scan_op=""
[[ "$load_type" == "app_configs" ]] && scan_op="runFileOp"
while IFS= read -r -d '' file; do
if [ -f "$file" ]; then
source "$file"
# echo "$load_type FILE $file"
fi
done < <($scan_op find "$folder_dir" -maxdepth 3 -type d \( -name 'resources' \) -prune -o -type f -name "$file_pattern" -print0)
fi
# Load the categories from the file into an array
if [ "$load_type" = "libreportal_configs" ]; then
if [ -f "$configs_dir/app_categories" ]; then
mapfile -t app_categories < $configs_dir/app_categories
fi
fi
}