LibrePortal/scripts/cli/commands/updater/cli_updater_header.sh
librelad 0679fd65b2 feat(updater): stepped upgrade engine — climbs a ladder, verifying each rung
Ties the ladder and the verifiers together behind a new verb:

  libreportal updater upgrade <app> [version] [--dry-run]

Per rung, and every part is load-bearing:

  snapshot (fail-closed) -> set version -> pull -> up -> VERIFY -> next

On failure anywhere: restore THIS rung's snapshot, put the version back,
stop, and leave the app on the last version it actually verified at. The
ladder never continues past a doubt.

A snapshot PER RUNG rather than one at the start, because upstream
migrations are usually one-way — Nextcloud 32's schema cannot be undone
by putting the 31 image back. The recovery guarantee is "restore the
snapshot from sixty seconds ago", which only holds if every rung has one.

Two gates before anything moves. An app with no <app>_upgrade_verify is
refused outright: the generic health check cannot see a half-finished
migration, so laddering on it would be a guess wearing a safety label.
And a ladder that cannot be computed end to end refuses rather than
attempting a partial climb.

`updater upgrade` is a separate verb from `apply` on purpose: apply moves
you WITHIN a release line (and may be automatic), upgrade moves you
BETWEEN lines and is always a deliberate act. Dry runs execute inline so
the plan is instant to read.

updaterSetAnchorVersion rewrites the image tag AND its version sentinel
together — updating only the image would leave the sentinel advertising
the old version, and the next config regeneration would silently revert
the app.

Tested with stubs against the real code paths: the no-verifier gate holds
and changes nothing; a dry run has zero side effects; the happy path
snapshots at each current version before moving; a verify failure on rung
2 of 3 stops with the app on rung 1, restored, and never touches rung 3;
a failed snapshot moves no version and pulls nothing; a container that
will not start is rolled back.

NOT yet exercised on a live install — no app here needs a ladder. The
first real run should be a dry run.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-13 00:04:33 +01:00

35 lines
2.1 KiB
Bash

#!/bin/bash
# App Updater Commands Header
# Shows available `libreportal updater` subcommands.
cliShowUpdaterHelp()
{
echo ""
echo "Available App Updater Commands:"
echo ""
echo " libreportal updater check [auto] - Refresh per-app version & vulnerability data"
echo " (auto = background mode: only scans when the data is"
echo " older than CFG_UPDATER_SCAN_INTERVAL minutes)"
echo " libreportal updater apply <app> - Update one app (snapshots it first; auto-rollback on failure)"
echo " libreportal updater apply-all [a,b] - Update a comma-list of apps (each snapshotted first)"
echo " libreportal updater upgrade <app> - Move an app BETWEEN release lines, one version at a"
echo " time (31→32→33→34). Snapshots and verifies every step,"
echo " and stops at the first doubt. Add --dry-run to just see"
echo " the plan, or a version to stop short of the newest."
echo " libreportal updater rollback <app> - Restore an app's most recent pre-update snapshot"
echo ""
echo "Every update takes a recovery snapshot via the Backup engine before"
echo "touching the app, so any update is reversible. These commands back the"
echo "WebUI Updates page (features/updater); actions run through the task system."
echo ""
echo "Automatic updates: each check enqueues the update for every app set to"
echo "CFG_<APP>_UPDATE_TYPE=auto (the default) — the same snapshot-first apply"
echo "as pressing Update, recorded in History as automatic. They install only"
echo "inside CFG_UPDATER_WINDOW (default 06:00-08:00 host time, right after"
echo "the nightly backups); checks still run all day. Set an app to 'manual'"
echo "on its Configure page to hold it back, or CFG_UPDATER_AUTO=false to"
echo "hold back every app. A build that fails is never auto-retried."
echo ""
}