LibrePortal/scripts/cli/commands/setup/cli_setup_commands.sh
librelad e3ec256265 fix(setup): stop "setup complete" from lying about a half-done install
Three coupled defects in the first-run wizard flow, all surfacing as
"it said complete but nothing was set up":

1. Zero-app installs sailed through. With no apps ticked, setup was just
   config+finalize, finished in seconds having installed nothing, and
   fast-forwarded to an empty App Center. Add a self-contained in-wizard
   confirm ("Install with no apps?") before submitting. Can't reuse the
   shared confirmation-dialog component — it isn't loaded this early in
   boot — so the dialog is rendered by the wizard itself and mounted on
   <body> to escape the aurora surface's FX-stacking rule.

2. finalize declared success unconditionally. It never inspected the
   per-app install tasks, so a failed app still yielded "your install is
   ready" + a redirect. Pass the setup group id to `setup finalize`; it
   now rolls up the group's app-install task results and logs a clear
   partial/failed verdict. The WebUI completion watcher gates the welcome
   toast + App Center hand-off on the whole group succeeding, not just on
   finalize completing — a failed app now keeps the user on the tasks page
   with an error toast instead of a false all-clear.

3. Setup task count was confusing (banner "of 2" while the page listed 3).
   On dev/git installs the topbar's dev-mode auto-enable raced the wizard's
   own CFG_DEV_MODE write and spawned a second, un-grouped config-update
   task mid-setup. Skip that auto-enable while a setup handoff is active
   (the wizard already persists CFG_DEV_MODE); it runs on the next load if
   still needed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: librelad <librelad@digitalangels.vip>
2026-07-06 18:31:15 +01:00

57 lines
1.3 KiB
Bash

#!/bin/bash
cliHandleSetupCommands()
{
local action="$initial_command2"
local arg1="$initial_command3"
case "$action" in
"apply")
if [[ -z "$arg1" ]]; then
isError "Missing payload. Usage: libreportal setup apply <base64-json>"
return 1
fi
setupApply "$arg1"
;;
"config")
if [[ -z "$arg1" ]]; then
isError "Missing payload. Usage: libreportal setup config <base64-json>"
return 1
fi
setupApplyConfig "$arg1"
;;
"finalize")
# Optional arg: the setup group id, so finalize can roll up the
# per-app install results for this run.
setupApplyFinalize "$arg1"
;;
"status")
if isSetupWizardComplete; then
echo '{"complete":true}'
else
echo '{"complete":false}'
fi
;;
"reset")
setupWizardReset
isSuccessful "Setup Wizard lock cleared. The wizard will run again on next entry."
;;
"suggest-name")
setupGenerateName
;;
"dns-check")
setupCheckDomainPointsHere "$arg1"
;;
*)
cliShowSetupHelp
;;
esac
}