forked from idaholab/Malcolm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix idaholab#287; fix issue with SUPERUSER_API_TOKEN not being set co…
…rrectly after netbox-restore
- Loading branch information
Showing
2 changed files
with
111 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from django.contrib.auth.models import User | ||
from users.models import Token | ||
from os import getenv | ||
|
||
# adapted from | ||
# - https://github.com/netbox-community/netbox-docker/blob/b47e85ab3f2261021adf99ae9de2e9692fd674c3/docker/docker-entrypoint.sh#L74-L80 | ||
|
||
superUserName = getenv('SUPERUSER_NAME', '') | ||
superUserEmail = getenv('SUPERUSER_EMAIL', '') | ||
superUserPassword = getenv('SUPERUSER_PASSWORD', '') | ||
superUserToken = getenv('SUPERUSER_API_TOKEN', '') | ||
|
||
if not User.objects.filter(username=superUserName): | ||
u = User.objects.create_superuser(superUserName, superUserEmail, superUserPassword) | ||
Token.objects.create(user=u, key=superUserToken) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters