mirror of
https://github.com/evennia/evennia.git
synced 2026-03-28 18:47:16 +01:00
Make use of environmental variables for superuser creation
This commit is contained in:
parent
b0d85a3ae4
commit
34069b7447
1 changed files with 15 additions and 1 deletions
|
|
@ -1423,7 +1423,21 @@ def create_superuser():
|
|||
"\nCreate a superuser below. The superuser is Account #1, the 'owner' "
|
||||
"account of the server. Email is optional and can be empty.\n"
|
||||
)
|
||||
django.core.management.call_command("createsuperuser", interactive=True)
|
||||
|
||||
from os import environ
|
||||
if ("DJANGO_SUPERUSER_USERNAME" in environ) and ("DJANGO_SUPERUSER_EMAIL" in environ):
|
||||
username, email = environ["DJANGO_SUPERUSER_USERNAME"], environ["DJANGO_SUPERUSER_EMAIL"]
|
||||
django.core.management.call_command("createsuperuser", "--noinput",
|
||||
"--username=" + username,
|
||||
"--email=" + email, interactive=False)
|
||||
if "DJANGO_SUPERUSER_PASSWORD" in environ:
|
||||
password = environ["DJANGO_SUPERUSER_PASSWORD"]
|
||||
from evennia.accounts.models import AccountDB
|
||||
u = AccountDB.objects.get(username=username)
|
||||
u.set_password(password)
|
||||
u.save()
|
||||
else:
|
||||
django.core.management.call_command("createsuperuser", interactive=True)
|
||||
|
||||
|
||||
def check_database(always_return=False):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue