Commit graph

14 commits

Author SHA1 Message Date
lrnselfreliance
2b7bc4533f
upgrade: restart services when the upgrade fails before code changes (#669)
* upgrade: restart services when the upgrade fails before code changes

The upgrade script stops wrolpi-api and wrolpi-app before fetching, so a
failed fetch, signature verification, or checkout left the WROLPi down
with unchanged code on disk. The EXIT trap now restarts both services
for failures that occur before scripts/upgrade.sh begins modifying the
system. The post-checkout verification failure rolls the branch back to
the previously-running commit first, so services never restart on an
unverified commit.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* upgrade: only restart services when rollback lands on the known-good commit

Review fixes: a failed rollback no longer leaves the restart flag set, so
services cannot start on an unverified or mixed tree; the non-atomic
checkout failure path now rolls back too; trimmed narrative comments.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-19 18:52:53 -06:00
Roland
ce05a073dd
Upgrade: mark the pinned GPG key trusted in the throwaway keyring.
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Controller Tests / controller-tests (push) Waiting to run
Jest Tests / jest-tests (push) Waiting to run
verify-commit judges signature validity regardless of ownertrust, so the
upgrade's security model (possession of the pinned key is the trust
anchor) is unchanged — but gpg printed "WARNING: This key is not
certified with a trusted signature!" on every healthy upgrade, making
valid-signature logs look like something continued past a failure.
Import ownertrust for the sole key in the keyring to silence it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-06 20:57:01 -06:00
Roland
e6ace5942b
Disambiguate 'git checkout release' in upgrade.sh.
Same fix install.sh received in bf88ac9f: on a box with no local
release branch (installed before that patch), the tracked release/
directory makes a bare `git checkout -f release` fail with
"could be both a local file and a tracking branch", aborting upgrades.
`checkout -f -B <branch> origin/<branch>` is unambiguous and already
resets the branch to origin, replacing the separate reset --hard.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-05 13:03:11 -06:00
Roland
e8c6d8415b
Certificates: only include SANs permitted by the Root CA name constraints.
Global IPs from `hostname -I` (e.g. routable IPv6 assigned via SLAAC)
violated the Root CA's critical nameConstraints, failing leaf verification
with "permitted subtree violation" (error 47) and aborting
install/repair/upgrade. Filter SAN candidates, including EXTRA_SANS, to the
permitted private ranges and log skipped entries; normalize the IP:/DNS:
prefix case in EXTRA_SANS since openssl rejects lowercase prefixes.

Also guard the service stops in upgrade.sh so upgrading a box whose
install died before the units were installed can still recover.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-05 12:38:08 -06:00
Roland
f4d0468300
Force checkout in upgrade.sh so a dirty working tree can't abort the upgrade
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Controller Tests / controller-tests (push) Waiting to run
Jest Tests / jest-tests (push) Waiting to run
scripts/upgrade.sh runs `npm install`, which rewrites app/package-lock.json
and leaves the working tree dirty. The next upgrade's `git checkout ${BRANCH}`
then aborts with "Your local changes would be overwritten by checkout" before
the following `git reset --hard` can discard them, failing the upgrade with
exit 4.

Use `git checkout -f` so the branch switch discards local modifications; the
reset --hard immediately after already forces the tree to match origin, so the
intent (blow away local changes) is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-29 13:22:56 -06:00
Roland
e7591b16ad
Self-heal wrolpi-upgrade.service unit before delegating in upgrade.sh
upgrade.sh delegates to wrolpi-upgrade.service at the very start, but that
unit is only installed by repair.sh, which runs near the end of the upgrade.
On a box that has never run a repair since the unit was introduced, the
delegation fails immediately with "Unit wrolpi-upgrade.service not found",
the service never runs (so nothing is logged to the journal), and
/opt/wrolpi/upgrade.log is never created.

Install/refresh the unit from the checked-out tree and daemon-reload right
before starting the service. The delegation block already runs as root, so
no sudoers changes are needed. This is idempotent and also self-heals a
stale unit file.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-29 13:16:07 -06:00
Roland
d4ef9cf12f
Validating git commit against my gpg signing key during upgrade. Upgrade will not take place unless the git commit is correctly signed.
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Controller Tests / controller-tests (push) Waiting to run
Jest Tests / jest-tests (push) Waiting to run
2026-03-14 16:39:04 -06:00
Roland
14d4aa1df4
Changing ownership of tmp upgrade file so that wrolpi-upgrade can change it. 2026-02-05 08:52:54 -07:00
Roland
9cdc0b5085
Upgrade script does not report upgrade being complete when it actually fails.
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Controller Tests / controller-tests (push) Waiting to run
Jest Tests / jest-tests (push) Waiting to run
2026-02-03 16:53:20 -07:00
Roland
d697fc4603
upgrade.sh delegates to wrolpi-upgrade service so that logs are visible in controller, even if launched from terminal. 2026-02-03 16:42:06 -07:00
Roland
774090fc0a
Changing upgrade script to default to the current branch. 2025-12-23 17:22:40 -07:00
Roland
00579759cc
Using sudo when upgrading. 2023-11-22 10:40:56 -07:00
Roland
dc9384ba4b
Calling second upgrade script so new upgrades can be pulled from git. 2023-02-24 17:31:08 -07:00
Roland
abb0b49315
Checking for icesheet table as current user.
Importing maps as wrolpi user, then changing ownership to _renderd.

Changing ownership of /opt/wrolpi as well.

Creating pgpass for wrolpi user in debian 11.

Install specific version of serve.

Not echoing the echo.

Updating cache directory in create_db.sh.

Use python binary to run db upgrade.

Install renderd.conf to /etc on RPi OS.

Fetching DC map from wrolpi.org to avoid broken daily PBFs.

Only get latest dc map if it doesn't exist.

carto switched again??

Changing mod_tile directory to /var/cache/renderd/tiles for RPi OS.

Copying renderd configs for RPi OS.

Installing postgres 13 for RPi OS map.

Changing title of feature matrix.

Moving download link up in readme.

Changing mod_tile to _renderd.

Using unix socket rather than host connection.

Getting openstreetmap-carto as _renderd user.

Assigning ownership of gis db to _renderd in reset_map.sh.

Creating _renderd db user.

Using _renderd to run renderd on debian 11.

Installing python modules that map requires globally.

Upgrading db using venv.

Installing nodejs which installs npm.

Install npm/node after other dependencies.

Updating apt so nodejs can be installed.

Upgrading PyYAML in new venv.

Installing pip via apt.

Including bash binary for portability.

Moving images link out of list.

Moving download up on Readme.

Removing map installation from readme.

Installing specific version of carto.

Creating venv for wrolpi project.  Using venv to install requirements and run wrolpi's main.py.

Logging upgrade script.

Including upgrade script in Upgrade readme.

Moving upgrade logic into separate script.  This is necessary so and repo update will take immediate effect on the upgrade.

Modifying and unifying Debian installation with RPi OS installation.
2023-02-24 16:16:13 -07:00