Native install: mandatory install directory, UI delivered from the repository

- install.sh always asks for the install directory (--prefix or a prompt
  with confirmation, no default); refuses system directories, the
  repository checkout itself, paths inside/containing it and non-empty
  directories (a resumed install is allowed). A preflight refusal says
  nothing was changed.
- UI is part of the repository: committed build in deploy/ui-dist with
  SOURCE_HASH and a staleness guard (check-ui.sh, loud warning). install.sh
  and update.sh resolve the UI: --ui-dist FILE|DIR, --build-ui, committed
  build; install stops without a UI unless --no-ui. update.sh swaps the UI
  when its hash differs from the installed one (.ui-source-hash).
- build-ui.sh: --docker, --local (host Node >= 20.19, temporary copy),
  --node-download (portable Node, SHA-256 verified), --publish.
- Verified on Alpine 3.23: install without UI options installs the real UI;
  local build equals the Docker build; update skips an unchanged UI and
  warns on a stale build. --node-download is untested (needs network).
- Docs: Scenario 2 guide, change summary, plan, README.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ayurishchevandClaude Sonnet 5.5 committed 2026-10-05 12:38:18 +03:00
1 parent 4abd2044f0
commit 8371d889a4
31 files changed
+920 -114

No files matched your search

@@ -38,6 +38,49 @@ Phase 3 of [Deployment_Scenarios_PLAN](2026-10-05_Deployment_Scenarios_PLAN.md).
Test containers, images and the UI archive were removed afterwards.
## Follow-up: the install directory is always asked for
A first run on a clean Alpine 3.24 host failed with "an installation already exists": the repository had been cloned straight into `/opt/OpenVPN-Monitoring-Simple`, the default prefix, and the preflight took the checkout's `APP_CORE` for an installation. My tests always ran from a separate source directory, so this was not caught.
| Change | Detail |
|---|---|
| `--prefix` is mandatory | No default any more: the option, or an interactive prompt with a confirmation; without a terminal the script stops. `/opt/OpenVPN-Monitoring-Simple` is only a suggestion |
| Prefix checks (before anything is changed) | absolute and normalised path; not a system directory (the installer sets permissions on it, `chmod 755 /root` would be harmful); not the repository checkout, not inside it, not containing it; new or empty (a resumed install is allowed); an existing non-empty directory is refused and points to `update.sh` |
| Not done on purpose | An "install in place" mode (checkout = install directory) was drafted and dropped: with the source and the install directory separated it is unnecessary, and a rollback after a `git pull` in place was not verified (the git `HEAD` could stay on the new commit while the files are restored) |
| Messages | A refusal in preflight now says "nothing was changed on this system"; a later failure says to rerun with the same `--prefix` |
| `update.sh`, `backup.sh`, `restore.sh` | Unchanged: they read the prefix from `/etc/ovpmon/deploy.state`. Adoption of a hand-made installation by `update.sh` (including a checkout used as the install directory) stays as it was |
| `.gitignore` | `__pycache__/` and `*.pyc` |
Checked without installing anything: system directories, the checkout itself, a path inside the checkout, `..`/relative/trailing-slash paths, a missing `--prefix` without a terminal, and the interactive prompt (empty answer, system directory, the checkout, a valid path declined three times) all stop before any change; nothing was created on the host.
## Follow-up: the UI is part of the repository (plan: [UI_Delivery_PLAN](2026-10-05_UI_Delivery_PLAN.md))
Incident: `install.sh` without `--ui-dist` installed only a placeholder page, so after the install "the UI was not there". The UI is now delivered like any other part of the checkout.
| Change | Detail |
|---|---|
| Committed build | `deploy/ui-dist/` (build of `APP_UI`) with `SOURCE_HASH`; refreshed by a maintainer with `deploy/native/build-ui.sh --publish` before committing UI changes. Outside `APP_UI`, so the container builds are unaffected; `deploy/ui-dist` is in `.dockerignore` (the all-in-one image builds the UI itself); `.gitignore` does not ignore it |
| `ui_source_hash` (`lib.sh`) | SHA-256 over `src/`, `public/`, `index.html`, `package.json`, `package-lock.json`, `vite.config.js`, `jsconfig.json` (relative paths in `LC_ALL=C` order, hash per file, hash of the list; never `node_modules`/`dist`); busybox and GNU (`sha256sum`, or `shasum` on macOS). One function for `build-ui.sh`, `check-ui.sh`, `install.sh`, `update.sh` |
| `check-ui.sh` | prints `fresh`, `stale` or `missing`; exit 0, 1, 2 |
| Staleness guard | committed build older than the sources: a loud, precise warning in `install.sh`/`update.sh` (hashes, `build-ui.sh --publish` for maintainers, `--build-ui` for the host); not fatal |
| Order (`install.sh`, `update.sh`) | `--ui-dist FILE\|DIR`, `--build-ui`, committed `deploy/ui-dist`, (install only: `deploy/native/ui-dist.tar.gz`); nothing found: `install.sh` stops unless `--no-ui` (placeholder only then); `update.sh` keeps the installed UI |
| Web root hash | `/var/www/ovpmon/.ui-source-hash`; `update.sh` skips the UI swap when the repository build has the same hash, otherwise swaps it in phase 6 (inside the backup and the automatic rollback); the source is decided after `git pull` |
| `stage_ui` | accepts a tarball or a directory, validates `index.html` before the live web root is touched, same atomic swap |
| `build-ui.sh` | default unchanged in effect (tarball), now Docker if it works else local; `--docker`, `--local` (`npm ci` in a temporary copy of `APP_UI`, Node >= 20.19 check, per-OS instructions), `--node-download` (official Node 20, SHA-256 verified, glibc only, temporary), `--publish`, `--check`, `--repo`; tarballs contain `SOURCE_HASH` |
Checked on a temporary copy of the repository (nothing installed, no service touched): `sh -n`/`bash -n` of all scripts; `ui_source_hash` identical under dash, bash and busybox sh and equal to an independent Python computation, unaffected by `node_modules`, `dist` and `.DS_Store`, changed by a source edit; `check-ui.sh` fresh/stale/missing with exit codes; `ui_resolve` and `stage_ui` for a directory, a tarball with and without `SOURCE_HASH`, an invalid source and the fallback archive; `build-ui.sh --local --publish -o` with a stub `node`/`npm` (old Node refused with instructions, source tree stays clean, `deploy/ui-dist` and the tarball written, check says fresh); `ui_resolve --build-ui` through the default Docker builder produced a real tarball whose `SOURCE_HASH` equals the hash of the sources. Not tested here: `--node-download` (needs nodejs.org), `--docker --publish` on the real tree, a real install and update with the new UI logic on a host, and `build-ui.sh --local` with a real Node.
Real runs after the implementation (Alpine 3.23 container with OpenRC; Docker only for the maintainer build):
| Check | Result |
|---|---|
| `build-ui.sh --publish` (Docker) and `check-ui.sh` | `deploy/ui-dist` (1.3 MB) written, `fresh` |
| `install.sh --prefix ...` with **no UI option** (the incident) | The UI of the repository is installed automatically: real index page (`OpenVPN Controller`), `.ui-source-hash` equals `SOURCE_HASH`, HTTPS health check 200 |
| `build-ui.sh --local` with the distribution's Node (v24, no Docker) | Builds in a temporary copy; the source tree stays clean (no `node_modules`, no `dist`); the archive's `SOURCE_HASH` equals the Docker build's |
| `update.sh`, UI sources unchanged | "UI: unchanged (same sources as the installed UI)", no swap |
| `update.sh`, a UI source changed after the build | Loud warning that the committed build is older than the sources and how to fix it; the update still completes |
| Not run | `--node-download` (needs the network and nodejs.org), Debian/Ubuntu runs of the new UI logic, `install.sh --build-ui` on a host |
## Notes and limits
- A container is not a host: no real firewall, cgroup and init details can differ. Run the procedure once on a VM of the target OS before production. Test containers needed explicit help (an init process for OpenRC, writable cgroup); these are test artefacts, not product defects.
@@ -0,0 +1,45 @@
# UI delivery for system-service installs: plan (2026-10-05)
Problem: `install.sh` without `--ui-dist` installed only a placeholder page and merely warned. After the install "the UI is not there". The owner proposes two ways, both wanted:
1. Keep an up-to-date UI build in the repository and use it at install time.
2. Allow building the UI without a container.
The install script must treat the UI as a normal part of the repository and install it automatically.
## Design
### Committed build (`deploy/ui-dist/`)
- The built UI (index.html, assets, ...) is committed in `deploy/ui-dist/` together with `SOURCE_HASH`: a SHA-256 over the UI sources it was built from (`APP_UI/src`, `public`, `index.html`, `package.json`, `package-lock.json`, `vite.config.js`, `jsconfig.json`; sorted, `LC_ALL=C`). It sits outside `APP_UI` so the container builds (which copy `APP_UI`) are not affected.
- Staleness guard: install and update compare the hash of the current `APP_UI` sources with `SOURCE_HASH`. Equal = fresh. Different = the build is older than the sources: a loud warning, the build is still used unless a better source is selected (see order). `deploy/native/check-ui.sh` exits 1 when the committed build is stale (for maintainers, before a commit or a release).
- The installed web root records the hash it was installed from (`<webroot>/.ui-source-hash`), so `update.sh` knows when the UI changed.
### Building without a container
`build-ui.sh` modes (default: Docker if available, otherwise local):
- `--docker`: as now (node:20-alpine).
- `--local`: Node on the build host. Uses the system Node when it is 20.19 or newer; otherwise it stops with exact instructions per OS (Alpine: `apk add nodejs npm`; Debian/Ubuntu: Node 20+ from the Node.js distribution) or, with `--node-download`, fetches the official Node 20 LTS archive (glibc, x86_64/aarch64) into a temporary directory, verifies it against the published SHA-256 sums, builds and deletes it again (nothing is installed on the host).
- `--publish`: after the build, refresh `deploy/ui-dist/` and `SOURCE_HASH` in the repository (maintainer action); `-o FILE` still writes a tarball for another host.
### UI source order in `install.sh` and `update.sh`
1. `--ui-dist FILE|DIR` (tarball or directory), explicit.
2. `--build-ui` (build now from `APP_UI`, Docker or local as above; for hosts where the committed build is stale or missing).
3. The committed `deploy/ui-dist/` found in the repository checkout (automatic).
4. Nothing found: **install stops** with the reasons and the ways out, unless `--no-ui` is given (placeholder page on purpose). `update.sh` keeps the installed UI when no source is found.
`update.sh` installs the repository build automatically when its hash differs from the installed one; `--ui-dist` and `--build-ui` still override.
## Steps
1. `deploy/native/lib.sh`: `ui_source_hash`, `ui_resolve` (the order above), `stage_ui` accepting a directory as well as a tarball, hash file in the web root.
2. `deploy/native/build-ui.sh`: `--docker`, `--local`, `--node-download`, `--publish`; Node version check.
3. `deploy/native/check-ui.sh`.
4. `install.sh` and `update.sh` use `ui_resolve`; new options `--build-ui`, `--no-ui`; clear messages.
5. Commit the current build in `deploy/ui-dist/` (built with `build-ui.sh --publish`); `.gitignore`, `.dockerignore` adjustments.
6. Documentation: Scenario 2 guide (UI section rewritten: three ways, staleness, maintainer routine), README quick start, change summary.
## Verification
- `check-ui.sh` on a fresh and on a deliberately stale tree.
- `build-ui.sh --local` on an Alpine container with the distribution's Node (no Docker inside), and `--publish` with Docker.
- Alpine install in a container without any UI option: the UI is installed automatically from the repository and served (HTTP 200, real index page, not the placeholder).
- Update with an unchanged and with a changed UI hash.
## Out of scope
CI that rebuilds the UI on every commit, a pre-commit hook, Node installation through the package manager by the scripts.
+77 -24
View File
@@ -1,10 +1,11 @@
# Scenario 2: installation as system services (no containers)
Install and update on **Alpine (OpenRC)**, **Debian** and **Ubuntu** (systemd) with the scripts in `deploy/native/`. Nothing runs in a container, nothing needs Node on the host.
Install and update on **Alpine (OpenRC)**, **Debian** and **Ubuntu** (systemd) with the scripts in `deploy/native/`. Nothing runs in a container. The web UI is part of the repository (`deploy/ui-dist`) and is installed automatically, so the host needs no Node.
| Script | Purpose |
|---|---|
| `deploy/native/build-ui.sh` | builds the web UI in a Node 20 container into `ui-dist.tar.gz` (on any machine with Docker) |
| `deploy/native/build-ui.sh` | builds the web UI (Docker, or the local Node without a container) into a tarball and/or into the repository (`--publish`) |
| `deploy/native/check-ui.sh` | checks that the committed UI build `deploy/ui-dist` matches the `APP_UI` sources (exit 1 when stale) |
| `deploy/native/install.sh` | first installation: packages, user, code, virtualenvs, configuration, services, nginx with TLS, health checks |
| `deploy/native/update.sh` | update with a verified backup, a separate database migration step and automatic rollback; `--rollback` for a manual one |
| `deploy/native/backup.sh` / `restore.sh` | stand-alone backup (cron friendly) and restore |
@@ -41,31 +42,75 @@ Another version of these systems is refused with a warning unless you pass `--fo
- Free space: about 1 GB for the code and virtualenvs (the script checks it), plus room for the backups.
- Python 3.9 or newer (Alpine 3.23: 3.12, Debian 12: 3.11, Ubuntu 24.04: 3.12).
- Free TCP ports `5001`, `8000` (on `127.0.0.1`) and the HTTPS port (default `8088`).
- The UI archive (see below). **The host needs no Node.js.**
- A UI build: the clone contains one (`deploy/ui-dist`, see below). **The host needs no Node.js** unless you choose `--build-ui`.
- GNU tar (on Alpine the package `tar`; the installer adds it).
## Building the UI (any machine with Docker)
## The web UI
```bash
deploy/native/build-ui.sh # -> deploy/native/ui-dist.tar.gz
deploy/native/build-ui.sh -o /tmp/ui.tar.gz # another output file
OVPMON_NODE_IMAGE=node:20-alpine deploy/native/build-ui.sh --image node:22-alpine
The UI is built from `APP_UI` (Vue/Vite). The repository carries a ready build in `deploy/ui-dist/` together with `SOURCE_HASH`, a SHA-256 over the UI sources it was built from (`APP_UI/src`, `public`, `index.html`, `package.json`, `package-lock.json`, `vite.config.js`, `jsconfig.json`). `install.sh` and `update.sh` find the UI themselves. The directory is outside `APP_UI`, so the container builds are not affected.
### Three ways to get the UI onto a host
| Way | Option | When |
|---|---|---|
| Committed build | none (automatic) | the normal case: `git clone`, `install.sh`, done; no Node, no Docker |
| Build on the host | `--build-ui` | the committed build is stale or missing; builds from `APP_UI` now with Docker (when its daemon works) or the host's Node 20.19+ |
| Build elsewhere | `--ui-dist FILE\|DIR` | a tarball from `build-ui.sh` or a directory with `index.html`, for example from a CI job or another machine |
Order used by `install.sh` and `update.sh`: **1.** `--ui-dist` (explicit, always installed), **2.** `--build-ui` (always builds fresh from the sources), **3.** the committed `deploy/ui-dist` of the checkout (automatic), **4.** nothing found: `install.sh` **stops** (it lists the ways out) unless `--no-ui` is given (a placeholder page on purpose); `update.sh` keeps the installed UI. `install.sh` also still accepts `deploy/native/ui-dist.tar.gz` as a last resort below the committed directory. `--ui-dist` and `--build-ui` exclude each other.
The installed web root records the hash it came from in `/var/www/ovpmon/.ui-source-hash` (`unknown` for archives that were not made by `build-ui.sh`). `update.sh` compares it with the `SOURCE_HASH` of the repository build: equal, the UI is not replaced (and it says so); different or missing (for example a host installed with `--no-ui`), the new UI is staged in phase 3 and swapped in phase 6, with the rest of the update, so it is part of the backup and the automatic rollback. The UI source is decided after `git pull`, so a pulled new build is used in the same run. The old UI is in the backup.
### Staleness guard
When the hash of the current `APP_UI` sources differs from `SOURCE_HASH`, the committed build is **older than the sources** (someone changed the UI and did not refresh the build). `install.sh` and `update.sh` then print a loud warning with the two hashes and the remedy, and still use the committed build (it works, it only lacks the latest UI changes). A host that needs the current UI adds `--build-ui`. A build without a valid `SOURCE_HASH` counts as stale.
### Maintainer routine
After every change in `APP_UI` (or its `package*.json`, `vite.config.js`), **before committing**:
```sh
deploy/native/build-ui.sh --publish # rebuilds deploy/ui-dist/ and SOURCE_HASH from the current sources
deploy/native/check-ui.sh # prints fresh | stale | missing; exit 0 | 1 | 2
git add APP_UI deploy/ui-dist
```
The script runs `npm ci` (or `npm install` without a lock file) and `npm run build` in `node:20-alpine`. `APP_UI` is mounted read-only and copied inside the container, so **nothing is written into the source tree** except the output file. The archive holds the content of `dist/` with `index.html` at its top level. Without Docker the script stops with a clear message; you can then build elsewhere (`npm install && npm run build` in `APP_UI`) and pack `dist/` yourself (`tar -czf ui-dist.tar.gz -C dist .`).
`check-ui.sh` also fits a release checklist or a CI step (it changes nothing). `--publish` replaces the content of `deploy/ui-dist/` by a move (the old directory is only deleted after the new one is in place).
Copy the archive to the target host together with the repository checkout and pass it with `--ui-dist FILE`. `install.sh` also picks up `deploy/native/ui-dist.tar.gz` automatically when it exists; `update.sh` uses a UI archive only when you pass `--ui-dist` explicitly (it never reinstalls a stale one).
### build-ui.sh
```sh
deploy/native/build-ui.sh # Docker if it works, otherwise local Node -> deploy/native/ui-dist.tar.gz
deploy/native/build-ui.sh --docker # node:20-alpine container (OVPMON_NODE_IMAGE or --image to change)
deploy/native/build-ui.sh --local # Node >= 20.19 and npm of this machine, no container
deploy/native/build-ui.sh --local --node-download # temporary official Node 20, deleted after the build
deploy/native/build-ui.sh --publish # refresh deploy/ui-dist/ in the repository
deploy/native/build-ui.sh -o /tmp/ui.tar.gz # tarball for another host (also with --publish)
deploy/native/build-ui.sh --check # only check that the builder is usable
```
Without `--docker`/`--local` the script uses Docker when its daemon answers, otherwise the local Node. The tarball holds the content of `dist/` and `SOURCE_HASH`. **Nothing is written into the source tree**: a container sees `APP_UI` read-only; `--local` copies it (without `node_modules` and `dist`) into a temporary directory and runs `npm ci` there (`npm install` without a lock file), so the repository gets no `node_modules` and no `dist`.
`--local` needs Node 20.19 or newer with npm. When it is missing or too old the script prints what to do and stops:
| System | What to do |
|---|---|
| Alpine | `apk add nodejs npm` (check `node --version` afterwards) |
| Debian / Ubuntu | the distribution's Node is usually too old (Debian 12 and Ubuntu 24.04 ship Node 18): add `--node-download` (needs `apt-get install -y curl xz-utils`), or install Node 20+ with npm from nodejs.org / NodeSource |
| anything else | Node 20.19+ from nodejs.org, or build with `--docker` on a machine with Docker |
`--node-download` fetches `SHASUMS256.txt` from `https://nodejs.org/dist/latest-v20.x/`, picks `node-v20.*-linux-<x64|arm64>.tar.xz`, verifies its SHA-256, unpacks it into a temporary directory (npm cache included), builds with it and deletes everything; nothing is installed on the host. glibc systems only: on Alpine (musl) it refuses and points to `apk add nodejs npm`. It needs `curl`, `tar`, `xz` and access to nodejs.org (`OVPMON_NODE_MAJOR` selects another major version).
## Install
Clone the repository on the target host, put the UI archive next to the scripts and run, as root:
Clone the repository on the target host (anywhere **outside** the install directory: the checkout is only the source, e.g. `/root/ovpmon-src`) and run, as root. The UI comes with the clone (`deploy/ui-dist`, see above). The install directory is always asked for: pass `--prefix DIR`, or the script prompts for it (and for a confirmation); there is no default. Recommended: `/opt/OpenVPN-Monitoring-Simple`.
### Alpine (OpenRC)
```sh
apk add git # only to clone; the script installs the rest
git clone <repository> /root/ovpmon-src && cd /root/ovpmon-src
deploy/native/install.sh --ui-dist /root/ui-dist.tar.gz
deploy/native/install.sh --prefix /opt/OpenVPN-Monitoring-Simple
```
### Debian 12
@@ -73,7 +118,7 @@ deploy/native/install.sh --ui-dist /root/ui-dist.tar.gz
```sh
apt-get update && apt-get install -y git
git clone <repository> /root/ovpmon-src && cd /root/ovpmon-src
deploy/native/install.sh --ui-dist /root/ui-dist.tar.gz
deploy/native/install.sh --prefix /opt/OpenVPN-Monitoring-Simple
```
### Ubuntu 24.04
@@ -82,15 +127,18 @@ deploy/native/install.sh --ui-dist /root/ui-dist.tar.gz
sudo -i
apt-get update && apt-get install -y git # make sure the "universe" component is enabled
git clone <repository> /root/ovpmon-src && cd /root/ovpmon-src
deploy/native/install.sh --ui-dist /root/ui-dist.tar.gz
deploy/native/install.sh --prefix /opt/OpenVPN-Monitoring-Simple
```
Options:
| Option | Meaning |
|---|---|
| `--prefix DIR` | install directory (default `/opt/OpenVPN-Monitoring-Simple`); letters, digits, `. _ - /` only |
| `--ui-dist FILE` | UI archive from `build-ui.sh`; without it a placeholder page is installed |
| `--prefix DIR` | install directory, **required**: asked interactively when the option is missing (without a terminal the script stops). Absolute path of letters, digits, `. _ - /`, no trailing `/`; must be new or empty, must not be the repository checkout (or contain it, or lie inside it) and must not be a system directory (`/`, `/opt`, `/root`, `/usr`, `/var`, ...) |
| `--ui-dist FILE\|DIR` | UI tarball from `build-ui.sh` or a directory with `index.html`; highest priority |
| `--build-ui` | build the UI now from `APP_UI` (Docker, otherwise the host's Node 20.19+) instead of using `deploy/ui-dist` |
| `--node-download` | with `--build-ui`: use a temporary official Node 20 (checksum verified, glibc only) |
| `--no-ui` | install a placeholder page on purpose; without any UI source and without this option the install stops |
| `--https-port N` | HTTPS port of the web UI (default `8088`) |
| `--host-name NAME` | DNS name or IP for the certificate and the CORS origin (default: the detected address of the default route) |
| `--admin-user NAME` | login of the first administrator (default `admin`) |
@@ -115,13 +163,13 @@ The nginx site does not collide with the distribution defaults: the default serv
| Phase | Content |
|---|---|
| 0 Preflight | root, OS and version, service manager present, no existing installation (otherwise it points to `update.sh`), source checkout complete, UI archive readable, ports free, free space |
| 0 Preflight | root, OS and version, service manager present, no existing installation (otherwise it points to `update.sh`), source checkout complete, UI source found (and built for `--build-ui`; a stale committed build only warns), ports free, free space |
| 1 Packages | the table above; GNU tar, Python 3.9+ with `venv` and `sqlite3`, `easy-rsa` checked |
| 2 User and directories | user `ovpmon`; `/var/lib/ovpmon` (+ `staging/`), `/var/log/ovpmon`, `/var/log/openvpn` (with `openvpn-status.log` as `root:ovpmon 640`), `/etc/openvpn/scripts`, `/etc/ovpmon` |
| 3 Code | `APP_CORE` and `APP_PROFILER` copied to the prefix (without venvs, databases, logs, Dockerfiles), plus the scripts and templates under `deploy/` and `DOCS/General/` (so the install directory can run `update.sh --source ...`); `VERSION` |
| 4 Virtualenvs and easy-rsa | two virtualenvs (`pip install -r requirements.txt`, plus `gunicorn` for `APP_CORE`), an import check, the easy-rsa workspace copied from `/usr/share/easy-rsa` into `APP_PROFILER/easy-rsa` (a real directory, never a symlink), code made root-owned and read-only |
| 5 Configuration | `/etc/ovpmon/env` (random secret, generated administrator), `/etc/ovpmon/helper.conf`, `/usr/local/sbin/ovpmon-helper`, doas rules and a **self-test** (`ovpmon` runs the helper through doas), forwarding via `/etc/sysctl.d`, OpenVPN prerequisites (Alpine: the `openvpn.conf` link; Debian/Ubuntu: `/etc/openvpn/server/`; the OpenVPN service is **enabled, not started**: there is no `server.conf` yet) |
| 6 Services, UI, nginx | the three service definitions installed and enabled, UI files to `/var/www/ovpmon`, a self-signed EC certificate (`/etc/ovpmon/tls/`, SAN: host name, detected IP, `127.0.0.1`, `localhost`), the nginx site, nginx enabled and reloaded |
| 6 Services, UI, nginx | the three service definitions installed and enabled, UI files to `/var/www/ovpmon` (validated, swapped in atomically, with `.ui-source-hash`), a self-signed EC certificate (`/etc/ovpmon/tls/`, SAN: host name, detected IP, `127.0.0.1`, `localhost`), the nginx site, nginx enabled and reloaded |
| 7 Start and checks | services started; health checks (below) |
| 8 Administrator | when a user exists in the monitoring database, the seed is removed from `/etc/ovpmon/env` and `ovpmon-api` is restarted; if the database cannot be read or is empty the seed stays and a warning says so |
@@ -237,7 +285,8 @@ Persistence:
```sh
deploy/native/update.sh # run from the checkout with the new version
deploy/native/update.sh --ui-dist /root/ui-dist.tar.gz # also replace the UI files
deploy/native/update.sh --ui-dist /root/ui-dist.tar.gz # install this UI (tarball or directory), always
deploy/native/update.sh --build-ui # build the UI from APP_UI on this host and install it
deploy/native/update.sh --source /root/ovpmon-src --yes # another checkout, no questions
deploy/native/update.sh --no-pull # sources already in place / offline
deploy/native/update.sh --rollback # manual rollback to the newest backup
@@ -249,13 +298,13 @@ Each phase is logged separately:
| Phase | What happens | If it fails |
|---|---|---|
| 0 Preflight | installation present, no unfinished install, source checkout complete, UI archive readable, services state, databases found, free space (backup and new code) | nothing was changed |
| 0 Preflight | installation present, no unfinished install, source checkout complete, an explicit UI source readable (`--build-ui`: builder usable), services state, databases found, free space (backup and new code) | nothing was changed |
| 1 **Backup** | verified backup in `/var/backups/ovpmon/<UTC timestamp>/` (see below) | the update is **refused**, nothing was changed |
| 2 Sources | `git pull --ff-only` of the source checkout (skipped with `--no-pull` or without git) | nothing was changed |
| 3 Prepare | new code copied to `<prefix>.new`, fresh virtualenvs with `pip install -r requirements.txt`, import check; new UI extracted next to the web root. **The running system is not touched** | nothing was changed |
| 3 Prepare | new code copied to `<prefix>.new`, fresh virtualenvs with `pip install -r requirements.txt`, import check; the UI source is decided (after `git pull`: `--ui-dist`, `--build-ui`, the committed build; unchanged hash means no swap) and the new UI is staged next to the web root. **The running system is not touched** | nothing was changed |
| 4 Stop and swap | the three application services are stopped (**OpenVPN keeps running**, VPN users stay connected); a final consistent snapshot; each code directory is renamed to `<dir>.old-<time>`, the new one moved in; **PKI, client profiles, `profiler.log`, `config.ini` and any database files below the code directory are moved over, never replaced**; virtualenv paths fixed | automatic rollback |
| 5 **Database migration** | its own step, see below | automatic rollback, **nothing is started** |
| 6 Files | UI swap; helper; `helper.conf` (when missing); doas rules; service definitions; missing environment keys added (existing values never changed); nginx site; each replaced only when it differs and is managed by these scripts; units reloaded | automatic rollback |
| 6 Files | UI swap (when a new UI was staged); helper; `helper.conf` (when missing); doas rules; service definitions; missing environment keys added (existing values never changed); nginx site; each replaced only when it differs and is managed by these scripts; units reloaded | automatic rollback |
| 7 Start | services started, health checks, helper self-test | automatic rollback |
| 8 Finish | the old code directories are removed (never one that still holds PKI data), the newest 5 backups kept, state recorded | |
@@ -348,7 +397,7 @@ A host that was set up by hand (the layout of the old guide: code in `/opt/OpenV
| `config.ini` of both components | Kept; the shipped one of the new version is saved as `config.ini.dist` when it differs |
| `profiler.log`, other `*.log` / `*.db` files below the code directories | Kept (moved) |
| Code, virtualenvs | **Replaced** (fresh virtualenvs; the old ones are in the backup) |
| UI files | Replaced only with `--ui-dist`; the previous ones are in the backup |
| UI files | Replaced with `--ui-dist` / `--build-ui`, or automatically when the committed build of the source differs from the installed one (`.ui-source-hash`); kept when there is no UI source; the previous ones are in the backup |
| Service definitions, nginx site, doas rules, helper | Replaced when they differ and are managed by these scripts; the previous ones are in the backup |
| User sessions | Stay valid while the secret is unchanged |
| Backups in `/var/backups/ovpmon` | The newest 5 kept, older ones pruned after a successful update; `-pre-restore` copies are never pruned automatically |
@@ -358,6 +407,7 @@ A host that was set up by hand (the layout of the old guide: code in `/opt/OpenV
| Symptom | Cause and action |
|---|---|
| `invalid --prefix ...` / `no valid install directory given` | The install directory must be a new or empty dedicated directory, not the repository checkout and not a system directory. Move or clone the repository elsewhere (for example `/root/ovpmon-src`) or choose another directory |
| `already installed ... use update.sh` / `an installation already exists` | `install.sh` never installs over an installation. Use `update.sh` (it adopts hand-made installations) |
| `installation stopped in phase ...` | Fix the cause and run `install.sh` again: it resumes and keeps secrets, certificate and data |
| `not a tested version ... needs --force` | Untested OS version: `install.sh --force` at your own risk |
@@ -372,7 +422,10 @@ A host that was set up by hand (the layout of the old guide: code in `/opt/OpenV
| Clients connect but have no internet | Forwarding or NAT is missing: see the firewall section |
| nginx: `conflicting server name` / port in use | Another site uses the same port; change `--https-port` (or the `listen` line of the site and reload) |
| Browser warns about the certificate | It is self-signed; check the fingerprint printed by `install.sh`, or install a real certificate under `/etc/ovpmon/tls/` and reload nginx |
| UI shows the placeholder page | Installed without `--ui-dist`: `deploy/native/update.sh --ui-dist FILE` |
| `no UI source found` (install stops) | The checkout has no `deploy/ui-dist` (incomplete clone, or the maintainer did not publish it) and no `--ui-dist`. Use `--build-ui` (Docker or Node 20.19+; `--node-download` on Debian/Ubuntu), `--ui-dist FILE\|DIR` from another machine, or `--no-ui` for a placeholder page |
| Warning "committed UI build ... is OLDER than the APP_UI sources" | Someone changed `APP_UI` without refreshing the build. Maintainers: `deploy/native/build-ui.sh --publish` and commit `deploy/ui-dist`. On the host: `--build-ui` |
| `the installed Node is too old` / `node and npm are not installed` (`--build-ui`, `build-ui.sh --local`) | The message lists the commands for the OS: Alpine `apk add nodejs npm`; Debian/Ubuntu `--node-download` or Node 20+ from nodejs.org |
| UI shows the placeholder page | Installed with `--no-ui`: run `deploy/native/update.sh` (installs the UI of the repository), or add `--ui-dist` / `--build-ui` |
| `su`/`doas` self-test fails on a minimal container | Containers often lack `/etc/pam.d/doas` or a real init system; the services may still work (check health) |
## Host hardening (recommended, not done by the scripts)