feat(install): one-command device registration for macOS, Windows and Linux

Registering a machine meant reading a multi-step page, installing Node, and
running three commands in the right order. Now it is one line per platform.

The hub serves scripts/install.sh and scripts/install.ps1 with its own address
and the enrolment token substituted in, so the published command carries
everything and there is nothing to fill in:

  curl -fsSL https://support.freakma.com/install.sh?token=TOKEN | sh
  irm https://support.freakma.com/install.ps1?token=TOKEN | iex

That output is piped straight into a shell, so the token — the only untrusted
value in either file — is refused unless it matches the base64url shape that
randomToken produces.

Each script checks for a usable runtime and stops with instructions rather than
guessing, warns when nothing is serving RFB on the loopback, installs per-user
with no root or administrator, and registers a login-scoped service: launchd on
macOS, a lingering systemd user service on Linux, a logon task on Windows. The
Windows script uses Node 22 when it is present and falls back to the bundled
executable otherwise, which is what lets one command cover both Windows 11 and
Server 2008 R2.

It registers a logon task rather than a service on purpose: services run in
session 0 and cannot draw on the interactive desktop, so the "ask first" consent
prompt would never appear.

Also adds /docs — a per-OS setup guide with service management and a
troubleshooting table — and reworks the enrolment page into OS tabs that open on
whichever platform the reader is sitting at.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-12 11:37:12 -07:00
co-authored by Claude Opus 5
parent cecaf74a0a
commit cfda6b19b7
11 changed files with 838 additions and 40 deletions
+54 -5
View File
@@ -90,15 +90,61 @@ LAN as the hub.
### Agent (the machine dials out)
**Invite a machine** produces a link. Open it on the target machine and it shows a
one-liner:
**Invite a machine** produces a link. Open it on the target machine and it shows the
command with the token already in it. The full walkthrough — per OS, with service
management and troubleshooting — is served at
[`/docs`](https://support.freakma.com/docs).
## Registering a device
One command per platform. The hub substitutes its own address and the enrolment token
into the script before serving it, so there is nothing to fill in but `TOKEN`.
**macOS and Linux**
```bash
curl -fsSL https://your-hub/download/agent.js -o rcs-agent.js \
&& node rcs-agent.js enroll https://your-hub/enroll/TOKEN \
&& node rcs-agent.js run
curl -fsSL https://support.freakma.com/install.sh?token=TOKEN | sh
```
**Windows**
```powershell
irm https://support.freakma.com/install.ps1?token=TOKEN | iex
```
**Windows 7 / Server 2008 R2** — PowerShell 2.0 has no `irm`, and .NET 3.5 does not
negotiate TLS 1.2 without [KB3154518](https://support.microsoft.com/kb/3154518), so
the short form fails twice over. From `cmd.exe`:
```bat
powershell -c "[Net.ServicePointManager]::SecurityProtocol=3072; (New-Object Net.WebClient).DownloadString('https://support.freakma.com/install.ps1?token=TOKEN') | iex"
```
What the scripts do, in order: check for a usable runtime and stop with instructions
rather than guessing; warn if nothing is listening on `127.0.0.1:5900`; download the
agent into a per-user directory; enrol, exchanging the one-time token for an agent key
written `0600`; and register a login-scoped service.
| Platform | Installs to | Kept alive by |
|---|---|---|
| macOS | `~/.rcs-agent` | launchd agent, `com.freakma.rcs-agent` |
| Linux | `~/.rcs-agent` | systemd **user** service `rcs-agent`, with lingering enabled |
| Windows | `%LOCALAPPDATA%\RemoteControlSupport` | logon task `RemoteControlSupportAgent` |
Nothing needs root or administrator. On Windows the installer uses Node 22 if it is
already there and falls back to the self-contained `rcs-agent.exe` otherwise, so the
same command works on a fresh Windows 11 box and on Server 2008 R2.
The Windows installer deliberately registers a **logon task, not a service**: services
run in session 0 and cannot draw on the interactive desktop, so the *ask first* consent
prompt would never appear and every session would time out waiting for an answer.
Both scripts are plain text and worth reading before piping them into a shell —
[`/install.sh`](https://support.freakma.com/install.sh) and
[`/install.ps1`](https://support.freakma.com/install.ps1) are exactly what runs.
### Doing it by hand
The agent needs Node 22+ and a VNC server listening on `127.0.0.1:5900`:
| OS | VNC server |
@@ -233,6 +279,9 @@ Everything is environment variables — see [.env.example](.env.example).
| `POST` | `/api/sessions/:id/kill` | admin |
| `GET` | `/api/sessions/history` | |
| `GET` | `/api/sessions/audit` | admin |
| `GET` | `/docs` | setup guide, no auth |
| `GET` | `/download/agent.js` · `/download/agent.exe` | no auth |
| `GET` | `/install.sh` · `/install.ps1` | no auth, `?token=` is stamped in |
| `POST` | `/api/public/enroll` | no auth, enrolment token |
| `POST` | `/api/public/session/:token` | no auth, support link |
| WS | `/ws/vnc?ticket=` | browser session |