Files
ShellBook/deploy
Florian Schmidt 399628bf16 feat(deploy): one-step install/update from the Proxmox host (#6)
bootstrap.sh runs on the Proxmox host via
  bash -c "$(curl -fsSL .../deploy/proxmox/bootstrap.sh)"
It unpacks the repository into a temporary directory, runs
create-ct.sh and removes everything again; create-ct.sh also removes
the installer files it pushed into the CT. Nothing stays on the host.

install.sh now installs or updates: an existing checkout is pulled
(fast-forward, SHELLBOOK_REF pins are kept), the service is restarted
and health-checked, and the summary prints the address, the one-time
setup token while setup is pending, the Claude login state and the
SSH public key.

It also installs a root-owned `shellbook-update` that downloads the
installer from the repository and reruns it. Root never executes
scripts from /opt/shellbook, which the service user and its terminal
panel can modify, so deploy/update.sh is removed.

Verified in a Debian 13 container: fresh install, then an update that
pulls a new commit while a tampered checkout script is not executed;
bootstrap.test.sh checks that host and CT keep no installer files.
2026-11-16 10:57:42 +01:00
..

Deploy ShellBook (M5 / #6)

Access is root-equivalent across managed hosts. Restrict CT port 8080 to the Traefik host with the Proxmox firewall; use HTTPS and limit the router to your LAN/Tailscale addresses. No password is set initially: API access fails closed.

  1. On the Proxmox VE 9 host, as root, run (installs or updates; nothing stays on the host):

    bash -c "$(curl -fsSL https://git.finalfactory.de/FinalFactory/ShellBook/raw/branch/main/deploy/proxmox/bootstrap.sh)"
    

    It unpacks the repository into a temporary directory, runs deploy/proxmox/create-ct.sh from it, and removes it again; the installer files pushed into the CT are removed too. Defaults: unprivileged Debian 13 CT 501, 2 cores, 2 GiB RAM, 16 GiB disk, DHCP on vmbr0, onboot, nesting and TUN. Overrides: CTID, CT_STORAGE, TEMPLATE_STORAGE, CT_BRIDGE, CT_IP (Proxmox ip syntax), CT_HOSTNAME, CT_CORES, CT_MEMORY, CT_DISK_GB. Existing CTs must be unprivileged Debian 13 of the host architecture; they may reboot when TUN passthrough is added. No raw config appending is used.

  2. Optionally supply SHELLBOOK_REPO, SHELLBOOK_REF, SHELLBOOK_HOST, SHELLBOOK_PORT, SHELLBOOK_TRUSTED_PROXIES (comma-separated proxy IPs), and TS_AUTHKEY in the host environment. Auth keys are transferred in a mode-0600 temporary file and removed, never stored in the service env.

  3. Open the address the installer prints and enter the one-time setup token it prints (also cat /var/lib/shellbook/setup-token in the CT) with a new password (at least 12 characters). The token survives restart, is deleted after setup, and the server never logs it; only the installer shows it to the admin running it. Alternative password CLI: SHELLBOOK_DATA_DIR=/var/lib/shellbook pnpm --filter @shellbook/server set-password from the checkout (hidden prompt or one password line on stdin; never arguments).

  4. Unless a Claude login already exists: Settings > "Open terminal to log in", then /login. Authorize /home/shellbook/.ssh/id_ed25519.pub on managed hosts. The service user has no sudo access. Initialize notebooks manually if templates were absent.

  5. Install the Traefik example in its file-provider directory and replace the hostname, CT address, TLS resolver and allowed networks. Set the actual Traefik peer IP in /etc/shellbook/env as SHELLBOOK_TRUSTED_PROXIES, then systemctl restart shellbook. Only configured proxies can influence HTTPS detection (and thus Secure cookies). TLS terminates at Traefik.

Standalone CT installation: run bash deploy/install.sh as root on Debian 13.

Updates: shellbook-update as root in the CT (from the Proxmox host: pct exec 501 -- shellbook-update), or rerun the bootstrap command. It downloads the installer from the repository (/etc/shellbook/installer-url, override with SHELLBOOK_INSTALLER_URL) and reruns it: pull (fast-forward; a SHELLBOOK_REF pin is kept), install, build, restart, health check. Env, password, workspace, SSH key, Claude login and session secret are preserved. Root never executes scripts from /opt/shellbook, which the service user (and the terminal panel) can modify. A failed build leaves the running service in place; check journalctl -u shellbook.

Configuration is /etc/shellbook/env; data is /var/lib/shellbook (back it up along with workspace and service-user home). SHELLBOOK_SESSION_SECONDS defaults to 2592000 (30 days). Cookies survive restart. Logout clears the browser cookie; Settings supports changing the password and signing out all sessions; both revoke older cookies and close active WebSockets, while the current browser receives a fresh cookie. CLI password changes invalidate cookies on their next request. For emergency revocation stop the service, delete session-secret, and restart it. Settings also shows paths, versions, and Claude CLI status, and opens the terminal for claude then /login as the service user. A credentials file's existence is only a hint, not proof that a login is valid.

Forward auth is off by default. To enable it set SHELLBOOK_FORWARD_AUTH_HEADER=Remote-User and trusted proxy IPs. The header is accepted only from an exact direct peer IP on that list (IPv4-mapped IPv6 is normalized). Traefik must strip incoming identity headers and set its own after authentication; block direct CT access. Built-in password login remains available. WebSocket clients must send the same session cookie; cross-origin API requests are rejected. Custom browser clients must use the public Host header.

Build choices: esbuild is a well-known TypeScript bundler; it bundles the source @shellbook/core via an explicit alias, while npm dependencies (including native node-pty) stay external. Production therefore retains installed node_modules. @fastify/static supplies Fastify-compatible static serving and safe file paths; the static directory is served only when index.html exists, with SPA fallback outside /api. Node 22 comes from nodejs.org's latest-v22.x binary release, verified with its SHA-256 manifest downloaded over HTTPS. This avoids third-party apt signing-key compatibility issues on Debian 13. Rerun the installer to update Node 22 security releases; unattended upgrades cover Debian packages only. Build tools support node-pty compilation. Claude uses its native installer.

Local deployment regressions: bash deploy/test/template-picker.test.sh and bash deploy/test/ct-config.test.sh, bash deploy/test/install-script.test.sh, bash deploy/test/bootstrap.test.sh (needs root; run it in a Debian container). Existing CTs with a manual TUN mount entry (earlier Tailscale setups) keep it; no dev0 is added on top. The scripts require bash, use LF endings, and avoid early-consuming pipelines under pipefail. Proxmox, systemd, Tailscale and SSH require deployment validation.