feat: env vars to auto-create user during initial setup #4706
+33
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Brief summary
Two new environment variables can be set:
INIT_USER_NAMEandINIT_USER_PASSWORD.If specified, Audiobookshelf automatically creates a superuser with the provided username and password at initial run, not asking user to provide this information via web-interface.
Which issue is fixed?
Fixes #4704
In-depth Description
Two new environment variables can be set:
INIT_USER_NAMEandINIT_USER_PASSWORD. IfINIT_USER_NAMEis set andINIT_USER_PASSWORDis not, then a user with empty password is created. If any user already exists, no changes are done.This allows us to provide root user data in environment variable (which is useful for container deployment) or via dev.js variables
InitUserNameandInitUserPassword.How have you tested this?
Running the container like that:
docker run -p 8080:80 -e INIT_USER_NAME=admin -e INIT_USER_PASSWORD=1234 ecf6aabecf96We can see log messages:
[2025-09-29 14:19:40.812] INFO: [Server] Auto-creating root user "admin" from environment variables [2025-09-29 14:19:40.851] INFO: [Server] Successfully auto-created root user "admin"During the login these credentials can be used, no "initial login" page is shown.
Screenshots
N/A