Create unprivileged server or worker LXCs and build native binaries inside the container. Refresh a clean published checkout before updates, preserve configuration and history, and roll back failed binary activation without resetting local source work. Refs #19
14 KiB
Proxmox LXC install and update
Run tools/proxmox.sh as root on the Proxmox host, from a trusted local copy of this checkout. It creates the container itself; do not run it inside an existing LXC. The default is a dashboard plus a collector/client in one new, unprivileged Debian 13 amd64 CT. This follows D14.
Use a checkout containing the web/worker and installer source. A public repository can be
cloned and updated over HTTPS without a Git login.
Alternatively copy the source to the host, including tools/proxmox/, tools/proxmox.sh, tools/source_policy.py,
LICENSE, root build files and the four Core/Fleet/Web/Worker source directories. Git metadata
and build artifacts are not needed. The installer snapshots the selected local source, including
uncommitted files; this local-source installer never pulls, commits or pushes Git changes.
The separate one-command updater refreshes a clean Git checkout
before invoking the installer.
The snapshot excludes recognized local configuration, key and runtime-data paths independently
of Git ignore rules; those files are not read or transferred with the source.
Install dashboard and client
From the copied repository root on the Proxmox host:
bash tools/proxmox.sh install --ctid 201 --storage local-lvm \
--domain usage.example.com --email [email protected] --timezone Europe/Berlin
Replace the storage, CT id, domain and email. Omit --ctid to ask Proxmox for the next free id.
--storage is deliberately required: the installer does not choose where to allocate your disk.
Add --dry-run to print the validated plan without calling Proxmox or changing files.
The installer:
- Downloads the latest available Debian 13 standard amd64 template to
local, or uses the filename selected with--template.--template-storageselects another template storage. - Creates an unprivileged CT, with on-boot startup, 2 cores, 4096 MiB RAM, 2048 MiB swap,
a 20 GiB root disk and DHCP on
vmbr0. It does not enable nesting or privileged mode. - Uploads an allowlisted source archive and builds
linux-x64NativeAOT inside the CT, as the separatefinaltoken-buildOS user. Windows-built executables are never deployed to Linux. - Installs the .NET 10 SDK/native compiler prerequisites in the CT, Caddy for HTTPS, and the
official Claude native stable installer and Codex npm package as the
finaltokenuser. Official CLI downloads run under that user, not root. No provider login is attempted. - Generates service keys, account/profile bindings, systemd services and a loopback web backend.
Caddy exposes
https://<domain>. The new client is automatically registered with this server. - Checks local services and the dashboard HTTP response. Keys are not printed by the script.
The host needs Proxmox's pct, pvesh, pveam, pvesm and Python 3. Its package repositories
are not changed. The CT needs working DNS and outbound package/download access. Native builds
need time and memory; increase --memory, --cores or --disk for a slower/smaller host.
The first build restores .NET packages. Later updates also run package installation in the CT;
this is not a fully offline or byte-for-byte reproducible supply-chain build.
For static networking:
bash tools/proxmox.sh install --ctid 201 --storage local-lvm \
--bridge vmbr0 --ip 192.0.2.20/24 --gateway 192.0.2.1 --vlan 10 \
--domain usage.example.com --email [email protected]
--vlan is optional. Set DNS to point the chosen domain to the CT. Allow incoming TCP 80/443
through your Proxmox/network firewall and, for public ACME certificates, forward the required
ports. The script sets the CT interface's firewall flag; it does not modify cluster/host firewall
rules, DNS, NAT or routing. The public certificate/network path is not proven by the local
health check. Caddy's default ACME certificate issuance needs the domain to be reachable.
For a private LAN hostname, add --tls internal. Caddy then uses a private CA; explicitly trust
its root certificate on browsers and remote clients. Do not disable TLS verification.
The root certificate is inside the CT at:
/var/lib/finaltoken-proxy/caddy/pki/authorities/local/root.crt
Read the dashboard access key from the Proxmox root console when you need to sign in:
pct exec 201 -- cat /etc/finaltoken/dashboard-key
Open the dashboard and use Log in / renew for each provider profile. This is the actual
official CLI login, bound to that CT's finaltoken user. The CLI still requires your browser
authorization. The client only observes coding activity in this CT's profiles; it cannot see
coding sessions on a desktop or a different CT unless a client is installed there too.
Claude quota probing remains subject to the web integration limitations.
Client-only or server-only
For a server-only container, run this as root on the Proxmox host after these changes are
published to master and anonymous HTTPS reads are enabled. The host needs Git in addition to
the Proxmox commands and Python 3. Use a new checkout path and a free CT id; replace the storage,
domain and timezone for your setup:
git clone --branch master --single-branch https://git.finalfactory.de/FinalFactory/FinalToken.git /opt/finaltoken-src && \
bash /opt/finaltoken-src/tools/proxmox.sh install --role server --ctid 201 \
--storage local-lvm --domain usage.example.com --timezone Europe/Berlin
This installs only the dashboard and HTTPS proxy. No provider login or provider email is required
on the server. Optional --email seeds the provider accounts; accounts and remote machine
bindings can also be configured afterwards. Set the domain's DNS and TCP 80/443 access as
described above. Private-LAN deployments can add --tls internal and trust the private CA.
Read the dashboard key with pct exec 201 -- cat /etc/finaltoken/dashboard-key.
Keep /opt/finaltoken-src as a dedicated deployment checkout for the update command below.
For a separate collector LXC, first configure an account/machine binding on the existing server
as described in the dashboard setup. The machine's osUser must
be finaltoken, with the selected provider ids as its profile ids. Put that machine's matching
transport key in a root-readable host file (mode 0600); it is a FinalToken key, not a provider token.
bash tools/proxmox.sh install --ctid 202 --storage local-lvm --role worker \
--server-url https://usage.example.com --machine-id lxc_202 \
--worker-key-file /root/lxc_202.key --email [email protected]
The script creates the client CT, installs its CLIs, configures profiles and starts its service.
The existing server must already authorize that machine id/key; this mode does not edit another
server's configuration. If the existing server uses a private CA, install that CA in the new CT's
system trust store with update-ca-certificates before expecting the worker to connect.
--role server omits the local client/CLIs and starts with no machine bindings. You can supply
--email to seed provider accounts, then configure remote machines in /etc/finaltoken/server.json
and add their distinct FINALTOKEN_MACHINE_<id> keys in /etc/finaltoken/server.env.
Restart the server after editing its configuration. The operator guide documents this static
configuration contract; there is no automatic remote enrollment HTTP API.
Use --providers codex or --providers claude to install only one provider.
--claude-email and --codex-email override --email independently. Machine ids must begin with
a letter and use letters/digits/underscores, because they also name systemd environment variables.
Update or resume a partial installation
For a clean clone at /opt/finaltoken-src, run this single command as root on the host
from any working directory. Change 201 to the installed CT id:
bash /opt/finaltoken-src/tools/proxmox-update.sh 201
It fetches the checkout's tracking branch with fast-forward-only/no-autostash rules, verifies that
HEAD matches that upstream, then enters the newly fetched installer. Re-running the command
with no new commit still retries deployment, which is useful after a package/build interruption.
The existing managed CT marker preserves the installed role, including server-only installations.
It refuses a detached branch, missing upstream, local-only commits and tracked/staged/untracked
changes; it never resets, stashes, commits or pushes local work. Upstream paths that would overwrite
ignored local files also stop the update. Ignored runtime state is retained
and filtered from source archives. Update failures return a nonzero exit status. Git failures
stop before deployment and do not echo remote URLs that might contain operator credentials.
The updater locks its checkout with flock (util-linux); the installer also holds its existing
host-wide deployment lock. Do not edit the dedicated clone during an update.
To validate the current source and deployment arguments without fetching or changing the CT:
bash /opt/finaltoken-src/tools/proxmox-update.sh 201 --dry-run
For a manually copied checkout or a deliberately selected local source snapshot, copy the desired new source into place and use the original offline-source entry point:
bash tools/proxmox.sh update --ctid 201
Use --source /absolute/path/to/another/checkout to select a different local source snapshot.
Update requires a running CT with this installer's marker and matching CT id. It refuses foreign
or stopped containers. It does not overwrite identity settings; install-only identity flags are
rejected on update. Service keys, configuration, CLI profiles and usage history are preserved.
Updates do not reinstall/upgrade the official CLIs; they keep their normal CLI-owned lifecycle.
A new binary release is built before the current symlink changes. Only services that were
running are restarted; intentionally stopped services remain stopped. A local health failure
restores the previous binary release and attempts to restart the previously running services.
That is binary rollback, not a history/configuration/OS-package rollback. Old releases are kept;
no automatic pruning or container deletion takes place. A future incompatible data schema needs
an explicit migration/backup plan before deploying it.
Restarting a server/client interrupts pending login attempts; finish or cancel them first.
An interrupted package download or build leaves the CT for inspection. Once the guest marker
exists, the same update command resumes an incomplete initial installation without rotating
its enrollment key. If creation failed before the marker was written, inspect the CT and its
network rather than trying to overwrite it with another install.
Files and service ownership
| Location | Purpose |
|---|---|
/etc/finaltoken/install.json |
Managed CT id, role, source checksum and last successful release |
/etc/finaltoken/server.json, worker.json |
Operator-editable account/profile configuration |
/etc/finaltoken/server.env, worker.env |
Root-only FinalToken service keys/environment |
/etc/finaltoken/transport-keys.json |
Root-only initial transport-key backup; not provider credentials |
/opt/finaltoken/releases/, /opt/finaltoken/current |
Root-owned staged/active native binaries |
/var/lib/finaltoken-server/ |
Server data; owned by finaltoken-server |
/var/lib/finaltoken-worker/ |
CLI profiles, per-provider history and collector state; owned by finaltoken |
/var/lib/finaltoken-proxy/ |
Caddy state/certificates; owned by finaltoken-proxy |
/var/cache/finaltoken-build/ |
Separate build user home/cache; per-build source directories are removed |
Generated units use separate non-root users, restrictive file permissions, no-new-privileges and
process-group shutdown. They avoid mount-namespace sandbox settings that require extra LXC
features. Unit files are created once and preserved on update; put site overrides in systemd
drop-ins. Default package caddy.service is disabled in favor of finaltoken-proxy.service.
pct exec 201 -- systemctl status finaltoken-server finaltoken-worker finaltoken-proxy
pct exec 201 -- journalctl -u finaltoken-worker -u finaltoken-server --since today
Application stdout/stderr are discarded by these units to prevent CLI/login material entering
the journal. The journal still shows service exit/restart metadata. Inspect configuration and
CLI installation under the intended user when diagnosing a failed service. Do not dump provider
credential files into logs or support reports. For coding inside the worker CT, use
pct enter 201, then su - finaltoken; its official CLIs are in ~/.local/bin.
Verification and limits
Run from the repository root:
python -B tools/proxmox/test_installer.py
python -B tools/proxmox/test_update.py
bash -n tools/proxmox.sh
bash -n tools/proxmox-update.sh
python -B tools/docs/check_docs.py
Installer tests mock Proxmox, package installation, native publishing and systemd. They cover argument validation, CT refusal, command order, environment isolation, archive safety, preservation of configuration/keys, partial setup, stopped services and activation rollback. They do not prove a real Proxmox create/update, Linux build, certificate issuance or provider login. No Proxmox host/container was changed while developing this script.
Updater tests use real local Git repositories and Bash with a synthetic installer. They verify two-version fast-forward deployment, no-change retry, dirty/diverged/ahead/detached refusal, fetch failure, dry-run, exit status, ignored-state retention and ignored-file collisions. Advisory lock command results are substituted so the checks also run on Windows; real Linux locking is not exercised here.
References: Proxmox CLI source, .NET on Debian, NativeAOT prerequisites, Caddy TLS, Claude installation, Codex installation. Source refresh uses Git fetch, fast-forward merge and flock.