Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Auto-Generate Internal Secrets

Many services need passwords or tokens that are generated once and used internally — database passwords, API secret keys, inter-container auth tokens. These are never shown to the user. Generate them at install time and store them in store.json for later consumption.

Solution

In setupOnInit, generate each secret whenever it is missing — not only on kind === 'install', so an existing install gains one the moment a release adds it — with utils.getDefaultString({ charset, len }), never Math.random or an alphabet of your own. Write them to store.json via a file model. These secrets are consumed in setupMain as env vars or config file values — they are never shown to the user.

Every install gets its own. A secret readable in the image or the repo — a secret_key written by the Dockerfile, a key constant in utils.ts, a fixed database password, an upstream sample config’s default — is the same on every server. When you find one, replace it with a generated value and rotate it for existing installs in a migration.

Reference: Initialization · File Models

Examples

See startos/init/ and startos/fileModels/ in: spliit, ghost, nextcloud, immich, jitsi, simplex, vaultwarden, gitea, synapse