fix(boot): source run_privileged.sh before checkConfigFilesMissingFiles

load_sources.sh calls checkConfigFilesMissingFiles() after init.sh +
variables.sh but BEFORE initilize_files.sh sources the function
manifest. checkConfigFilesMissingFiles uses runInstallOp (in
docker/command/run_privileged.sh) to copy missing config templates —
under LP_LAZY=1 that's an autoload stub that only exists once the
manifest is sourced. So when any template is genuinely missing, the
copy call hits "runInstallOp: command not found" and the file silently
never gets copied.

Symptom on a fresh CLI invocation (foreground or processor subprocess
inheriting LIBREPORTAL_TASK_EXEC=1) where a new config category was
added:
  config_check_missing.sh: line 33: runInstallOp: command not found
  ✓ Success 1 config files were missing and have been added to the
    configs folder.    ← false success: the count incremented but the
                         copy itself didn't happen

Fix: source run_privileged.sh directly in load_sources.sh just before
the missing-files check. The file is pure function definitions (runAsManager
/ runFileOp / runFileWrite / runInstallOp / runInstallWrite), no side
effects, ~150 lines — safe to source unconditionally and idempotent
with the eager/lazy load that happens later. Adds <1ms to every CLI
invocation; saves silent failures on the rare path that calls it.

Signed-off-by: librelad <librelad@digitalangels.vip>
This commit is contained in:
librelad 2026-05-27 14:58:43 +01:00
parent 68bade609b
commit 3294ca4e41

View File

@ -14,6 +14,16 @@ else
echo "Files are missing, please run 'libreportal reset'" echo "Files are missing, please run 'libreportal reset'"
fi fi
# checkConfigFilesMissingFiles uses runInstallOp (in docker/command/run_privileged.sh)
# to copy any missing config templates into place. That file's autoload stub
# isn't defined until the function manifest is sourced inside initilize_files.sh
# — which we haven't called yet at this point in load_sources. Source the
# privileged helpers eagerly so the reconciliation can do its work on a fresh
# install or after a config-template drift. The file is pure function defs;
# safe to source unconditionally.
[ -f "${install_scripts_dir}docker/command/run_privileged.sh" ] && \
source "${install_scripts_dir}docker/command/run_privileged.sh"
# Source config check # Source config check
if [ -f "${install_scripts_dir}config/core/config_check_missing.sh" ]; then if [ -f "${install_scripts_dir}config/core/config_check_missing.sh" ]; then
source "${install_scripts_dir}config/core/config_check_missing.sh" source "${install_scripts_dir}config/core/config_check_missing.sh"