Extends the install-routing spike (e5273a4) to every long-running CLI
command, so CLI and WebUI now share one execution path everywhere:
app install ← already done
app uninstall
app start / stop / restart / up / down / reload
app backup
app restore
update apply
backup app create (matches `app backup` — same end target)
Each handler now has the same shape:
if [[ "$LIBREPORTAL_TASK_EXEC" == "1" ]]; then
<inline call> # processor's recursive invocation
else
cliTaskRun "<cmd>" <type> <app> # user invocation: enqueue + follow
fi
Processor change — crontab_task_processor.sh:
Adds `export LIBREPORTAL_TASK_EXEC=1` next to LIBREPORTAL_NONINTERACTIVE.
Universal bypass: every task command the processor runs (CLI-queued OR
pre-existing WebUI-queued like `libreportal app install adguard`)
inherits the env var, so the inline branch fires and we never
re-enqueue. This also lets us drop the env-var prefix the install spike
was baking into the command string (e5273a4) — cleaner task files +
one place to think about the bypass.
`backup app schedule` (the cron-driven path that already enqueues via
createTaskFile in backup_app_schedule.sh) is left alone — different
entry point, different runtime context, already correctly task-routed.
Why route the fast ones too (start/stop/restart/up/down):
Consistency beats the ~1s task-roundtrip latency for a CLI button.
Locking now serialises a CLI `app stop foo` against a WebUI restart of
the same app; the audit trail covers every state change. Cheap to
revert any individually if the latency turns out to bother someone.
Validated live earlier with `libreportal app install dashy` — task file
written, processor dispatched, follower streamed install live, exit 0
propagated. Same machinery now powers the other 9 handlers.
Signed-off-by: librelad <librelad@digitalangels.vip>
36 lines
1.1 KiB
Bash
Executable File
36 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Update Commands Handler
|
|
# Handles all update subcommands by calling core functions
|
|
|
|
cliHandleUpdateCommands()
|
|
{
|
|
local update_type="$initial_command2"
|
|
|
|
case "$update_type" in
|
|
"")
|
|
# Interactive CLI updater (prompts the user).
|
|
checkUpdates
|
|
;;
|
|
"check")
|
|
# Non-interactive: force a fresh out-of-date check and rewrite
|
|
# update_status.json. Used by the WebUI "Check for updates" action.
|
|
webuiSystemUpdateCheck "force"
|
|
;;
|
|
"apply"|"now")
|
|
# Non-interactive update. Routes through the task processor
|
|
# (same path the WebUI's "Update now" button uses) so CLI
|
|
# and WebUI updates share locking + the audit trail.
|
|
if [[ "$LIBREPORTAL_TASK_EXEC" == "1" ]]; then
|
|
webuiRunUpdate
|
|
else
|
|
cliTaskRun "libreportal update apply" "update" "" ""
|
|
fi
|
|
;;
|
|
*)
|
|
isNotice "Invalid update command: ${RED}$update_type${NC}"
|
|
cliShowUpdateHelp
|
|
;;
|
|
esac
|
|
}
|