# Scenario 2: system services, Alpine, Debian, Ubuntu (2026-10-05) Phase 3 of [Deployment_Scenarios_PLAN](2026-10-05_Deployment_Scenarios_PLAN.md). Guide: [Scenario 2: system services](../Deployment/Scenario2_System_Services.md). ## What was added | Area | Content | |---|---| | `deploy/native/` | `install.sh`, `update.sh`, `backup.sh`, `restore.sh`, `build-ui.sh`, `lib.sh` (OS adapter for Alpine/OpenRC and Debian/Ubuntu/systemd), nginx template | | Install | Packages, `ovpmon` user, code, two virtualenvs, easy-rsa workspace, `/etc/ovpmon/env` (random secret, admin password shown once), root helper + `doas`, service definitions, OpenVPN prerequisites, nginx with TLS on 8088, health checks. The firewall is **not** touched (hints are printed) | | Update (phases) | preflight, **backup** (databases through the SQLite backup API, configuration, PKI, client configs, code with virtualenvs, system files; verified), source update, new code and virtualenvs prepared aside, **stop services (OpenVPN keeps running)** and swap code, **database migration as its own step** with the new code, UI/helper/doas/service files, start and health checks, **automatic rollback** from any failure after the stop | | UI build | `build-ui.sh` builds the UI in a Node 20 container into a tarball; the host needs no Node | | Debian/Ubuntu support in code | Root helper reads `/etc/ovpmon/helper.conf` (install dir, service manager `openrc|systemd`, unit, config path), validated strictly, defaults equal the old Alpine behaviour; `process.py` and `routers/server.py` use `OVPMON_RUNTIME`, `OVPMON_OPENVPN_SERVICE`, `OVPMON_OPENVPN_CONFIG`. Debian/Ubuntu: unit `openvpn-server@server`, config `/etc/openvpn/server/server.conf` | | Service definitions | `DOCS/General/systemd/*.service`, `DOCS/General/openrc/*` rewritten (user `ovpmon`, environment file, real commands, no `--reload`); `Service_Management.md` updated | | Docs | `DOCS/Deployment/Scenario2_System_Services.md`; `Deployment_Native.md` is a pointer | | Test | `APP_PROFILER/test_helper_config.py` (helper configuration, defaults, rejected values, command lines) | ## Defects found by the real runs and fixed | Defect | Fix | |---|---| | The profiler unit set `ProtectKernelTunables` and `ProtectKernelModules`: systemd implements them with seccomp and then sets NoNewPrivileges implicitly, so the setuid `doas` failed with "not installed setuid" and the root helper never ran | Both options removed from the profiler unit; the reason and the check are in the unit and in the guide | | OpenRC scripts replaced `PATH` in `start_pre`, dropping `/lib/rc/bin`: OpenRC itself failed with `ebegin: not found` | `PATH` is extended, not replaced (all three scripts) | | The helper syntax check used `py_compile`, which fails on a read-only source tree | `compile()` without writing a `.pyc` | ## Verification (containers with a real init: systemd on Debian 12 and Ubuntu 24.04, OpenRC on Alpine 3.23) | Check | Debian 12 | Ubuntu 24.04 | Alpine 3.23 | |---|---|---|---| | `install.sh`, health checks, admin seed removed | ok | ok | ok | | PKI init, server config through the root helper, client, note | ok | ok | ok | | OpenVPN started through the helper | `openvpn-server@server` | `openvpn-server@server` | `openvpn` (OpenRC) | | `update.sh` on databases without a version (real data) | ok, migration phase | ok | ok | | OpenVPN untouched by the update | same PID | active | active | | Rollback after an injected failure (broken new Profiler) | ok, data intact | not run | ok, data intact | | `backup.sh`, change, `restore.sh` | not run | ok | not run | | pytest: helper config test and the earlier tests | passed (all five test files) ||| Test containers, images and the UI archive were removed afterwards. ## 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. - Ubuntu 22.04 and other Debian or Alpine versions are not tested (the script warns and needs `--force`). - Not tested: BusyBox `su` paths on hosts other than the test image, an upgrade of an existing real Alpine host through `update.sh` (adoption without a state file is implemented, not exercised), a source tree that is itself the install directory. - Updates need access to the Python package index (fresh virtualenvs). - `openvpn-server@server` shows as failed at boot until a `server.conf` exists. - The version in the logs is `unknown` when `git` is not installed or the source is not a checkout. ## Existing installations An existing Alpine host installed by hand can be adopted: `update.sh` records the state on the first run. Keep a copy of `/etc/doas.d/*` and the helper before the first update; the update replaces files that carry the deploy marker and reports, but does not overwrite, files that differ and have none.