allow an initial user to be created from env vars

This commit is contained in:
gmega 2024-10-29 19:30:00 -03:00
parent d3007ad402
commit 398cde6f22
No known key found for this signature in database
GPG Key ID: 6290D34EAD824B18
1 changed files with 12 additions and 1 deletions

View File

@ -8,6 +8,7 @@ from dataclasses import dataclass
from typing import Optional, Dict from typing import Optional, Dict
from deluge.configmanager import ConfigManager, set_config_dir from deluge.configmanager import ConfigManager, set_config_dir
from deluge.core.authmanager import AuthManager
from deluge.core.preferencesmanager import DEFAULT_PREFS from deluge.core.preferencesmanager import DEFAULT_PREFS
@ -108,10 +109,20 @@ def main():
defaults['torrentfiles_location'] = options['DELUGE_TORRENTFILE_DIR'] defaults['torrentfiles_location'] = options['DELUGE_TORRENTFILE_DIR']
defaults['plugins_location'] = options['DELUGE_PLUGINS_DIR'] defaults['plugins_location'] = options['DELUGE_PLUGINS_DIR']
# Create default config.
manager = ConfigManager('core.conf', defaults=defaults) manager = ConfigManager('core.conf', defaults=defaults)
manager.save() manager.save()
# Create user.
auth_manager = AuthManager()
auth_manager.start()
auth_manager.create_account(
username=options['DELUGE_DAEMON_USERNAME'],
password=options['DELUGE_DAEMON_PASSWORD'],
authlevel='ADMIN',
)
auth_manager.update()
if __name__ == '__main__': if __name__ == '__main__':
main() main()