Unattended installation and configuration of OpenHAB - using Ansible for instance - is a nice way to recreate an OpenHAB environment or ‘clone’ a test setup, etc. (I know there are other ways, but that is not the point of my feature suggestion).
A manual step that cannot be skipped right now is the creation of the initial admin user through the UI.
What about a feature where OpenHAB checks for environment variables at first startup to specify the initial user parameters?
This mechanism is used quite common, especially when deploying container images. InfluxDB2 is an example where I can specify environment variables to control the one-off initial config, like this:
I guess it could also be part of the container image setup script, assuming there is some interface available that can check if it is an initial install and perform its magic. Checking if there is already a users.json would be one option.
And a similar issue exists for the token that can now only be generated in the UI. What about an option to provide OH with a self-generated token?
You can actually run a scripted console command on installation
Usage: openhab:users list - lists all users
Usage: openhab:users add <userId> <password> <role> - adds a new user with the specified role
Usage: openhab:users remove <userId> - removes the given user
Usage: openhab:users changePassword <userId> <newPassword> - changes the password of a user
Usage: openhab:users listApiTokens - lists the API tokens for all users
Usage: openhab:users addApiToken <userId> <tokenName> <scope> - adds a new API token on behalf of the specified user for the specified scope
Usage: openhab:users rmApiToken <userId> <tokenName> - removes (revokes) the specified API token
Usage: openhab:users clearSessions <userId> - clear the refresh tokens associated with the user (will sign the user out of all sessions)