Catch DoesNotExist preventing startup
Fixes failing startup because of python error: ``` Traceback (most recent call last): File "/opt/netbox/netbox/./manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line utility.execute() File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 440, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/base.py", line 402, in run_from_argv self.execute(*args, **cmd_options) File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/base.py", line 448, in execute output = self.handle(*args, **options) File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/commands/shell.py", line 127, in handle exec(sys.stdin.read(), globals()) File "<string>", line 2, in <module> File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/manager.py", line 85, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/query.py", line 650, in get raise self.model.DoesNotExist( users.models.Token.DoesNotExist: Token matching query does not exist. ```
This commit is contained in:
parent
ac8cb022ae
commit
29e37a31d7
@ -84,9 +84,12 @@ fi
|
||||
|
||||
./manage.py shell --interface python <<END
|
||||
from users.models import Token
|
||||
try:
|
||||
old_default_token = Token.objects.get(key="0123456789abcdef0123456789abcdef01234567")
|
||||
if old_default_token:
|
||||
print("⚠️ Warning: You have the old default admin token in your database. This token is widely known; please remove it.")
|
||||
except Token.DoesNotExist:
|
||||
pass
|
||||
END
|
||||
|
||||
echo "✅ Initialisation is done."
|
||||
|
Loading…
Reference in New Issue
Block a user