Skip to content

Improve config handling, add API-based config update - #554

Merged
TheNetsky merged 2 commits into
TheNetsky:v4from
mgrimace:main
Aug 1, 2026
Merged

Improve config handling, add API-based config update#554
TheNetsky merged 2 commits into
TheNetsky:v4from
mgrimace:main

Conversation

@mgrimace

@mgrimace mgrimace commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

This moves config generation and drift-detection out of the docker entrypoint.sh so both docker and bare metal can use it. Adds an API option POST /config/sync(gated behind API_ALLOW_CONFIG_WRITE) to update the config if new features are added, which keeps a user's existing config and adds the new keys with their defaults. Bare metal config loading (Load.ts/Validator.ts) is untouched.

Auto-update for the config can also be set with CONFIG_AUTO_SYNC=true, and is off (false) by default. Missing keys are written into config.json with their example defaults on every start (a .bak backup is kept). Existing values are never overwritten either way.

Changes

  • src/util/ConfigSync.ts (new) — single source of truth for generating config.json from the example and detecting/patching missing keys. Replaces duplicate diff/generation logic that previously lived in both bash and the API.
  • src/util/ConfigEnvOverrides.ts (new) — single source of truth for the CONFIG_* env var → config path mapping. Replaces the duplicate list that previously lived as both an entrypoint.sh comment block and its _cfg/_cfg_array calls.
  • entrypoint.sh (edited) — config generation, drift-checking, and env-override application now delegate to the two modules above, replacing ~275 lines of bash/jq.
  • scripts/api/configEditor.js (edited) — added diffConfig/syncMissingDefaults, thin wrappers around ConfigSync.ts, for use by the Control API.
  • scripts/api/server.js (edited) — added GET /config/diff and POST /config/sync routes exposing the above over HTTP.

Note: node dist/util/ConfigEnvOverrides.js list prints every supported CONFIG_* env var, the config path it maps to, and its type, useful as a live reference instead of the old hand-maintained comment block

@mgrimace

mgrimace commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Detection (default)
Screenshot 2026-07-31 at 5 59 05 PM

Auto-sync enabled
Screenshot 2026-07-31 at 5 58 49 PM

@mgrimace

mgrimace commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Note: this PR also fixes a small unrelated bug where ./scripts/envs.js which was added in a prior accounts update commit but was not available for docker users, I just added a line in the dockerfile to copy it into the image.
COPY --chmod=644 scripts/env.js ./scripts/env.js

@TheNetsky
TheNetsky merged commit 6e74c64 into TheNetsky:v4 Aug 1, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants