DocsReference

CLI

Commands for first-time setup, people, tokens, policies, audit checks and backups.

Run commands from the Gatehouse directory with npm run cli --. They use the same configuration as the server, so set the same environment variables (especially the master key) first. In Docker, prefix with docker compose exec gatehouse.

Commands

Command What it does
create-owner --email <e> --name <n> --password <p> Creates the first owner on a fresh install, without the setup code.
create-user --email <e> --name <n> --password <p> [--role owner|admin|auditor|member] [--teams a,b] Creates a person. --teams lists their groups.
create-token --email <e> --name <n> [--days 90] Prints a personal token for an agent or CI job.
reset-link --email <e> Prints a one-time password reset link, valid for 30 minutes, for when email isn't set up. Earlier unused links stop working.
set-password --email <e> Sets a password read from standard input, so it never appears in the process list or shell history. Applies the password rules, clears a lockout and cancels open reset links.
verify-audit Recomputes the audit hash chain and reports where it breaks, if anywhere.
export-policies Prints every policy as JSON.
import-policies <file.json> Replaces every policy (policy as code).
backup <file.db> Writes a consistent copy of the database. Safe while Gatehouse runs.

Examples

# Fresh install without the browser
npm run cli -- create-owner --email you@company.com --name "Your Name" --password '…'

# A token for a CI job that expires in 30 days
npm run cli -- create-token --email ci@company.com --name "Release bot" --days 30

# Policy as code
npm run cli -- export-policies > policies.json
npm run cli -- import-policies policies.json

# Someone is locked out and email isn't set up yet
docker compose exec gatehouse node src/cli.ts reset-link --email you@company.com

# Nightly backup
npm run cli -- backup /data/backups/gatehouse-$(date +%F).db

backup refuses to overwrite an existing file, so include the date in the name.