Compare commits

..

10 commits

Author SHA1 Message Date
Tobias Genannt cbd957d638
Merge 2127d2156a into 94dd752652 2026-01-08 11:46:52 +01:00
Tobias Genannt 94dd752652
Merge pull request #1592 from netbox-community/renovate/sentry-sdk-2.x
Some checks are pending
push / Builds new NetBox Docker Images (./build.sh main, ubuntu-24.04-arm) (push) Waiting to run
push / Builds new NetBox Docker Images (PRERELEASE=true ./build-latest.sh, ubuntu-24.04) (push) Waiting to run
push / Builds new NetBox Docker Images (PRERELEASE=true ./build-latest.sh, ubuntu-24.04-arm) (push) Waiting to run
push / Checks syntax of our code (push) Waiting to run
push / Builds new NetBox Docker Images (./build-latest.sh, ubuntu-24.04) (push) Waiting to run
push / Builds new NetBox Docker Images (./build-latest.sh, ubuntu-24.04-arm) (push) Waiting to run
push / Builds new NetBox Docker Images (./build.sh feature, ubuntu-24.04) (push) Waiting to run
push / Builds new NetBox Docker Images (./build.sh feature, ubuntu-24.04-arm) (push) Waiting to run
push / Builds new NetBox Docker Images (./build.sh main, ubuntu-24.04) (push) Waiting to run
chore(deps): update dependency sentry-sdk to v2.49.0
2026-01-08 11:46:48 +01:00
renovate[bot] 20cccc3869
chore(deps): update dependency sentry-sdk to v2.49.0 2026-01-08 10:09:25 +00:00
Tobias Genannt 2127d2156a Missing defaults 2026-01-08 10:45:24 +01:00
Tobias Genannt 269cf83362
Merge pull request #1590 from netbox-community/renovate/granian-2.x
chore(deps): update dependency granian to v2.6.1
2026-01-08 09:18:35 +01:00
Tobias Genannt 8c5cf9e26b Formatting 2026-01-08 09:10:05 +01:00
Tobias Genannt dde39aec65 Formatting 2026-01-08 09:06:10 +01:00
Tobias Genannt 14f669fe0d Formatting 2026-01-08 09:03:46 +01:00
Tobias Genannt 0cd10dd3b5 Review comments addressed 2026-01-08 08:14:59 +01:00
renovate[bot] da0784992e
chore(deps): update dependency granian to v2.6.1 2026-01-07 13:54:12 +00:00
4 changed files with 29 additions and 32 deletions

View file

@ -4,4 +4,4 @@ extend-ignore = E203, W503
per-file-ignores = per-file-ignores =
configuration/*:E131,E251,E266,E302,E305,E501,E722 configuration/*:E131,E251,E266,E302,E305,E501,E722
startup_scripts/startup_script_utils/__init__.py:F401 startup_scripts/startup_script_utils/__init__.py:F401
docker/*:E266,E722 docker/*:E266,E722,E501

View file

@ -54,25 +54,8 @@ fi
if [ "$SKIP_SUPERUSER" == "true" ]; then if [ "$SKIP_SUPERUSER" == "true" ]; then
echo "↩️ Skip creating the superuser" echo "↩️ Skip creating the superuser"
else else
if [ -z ${SUPERUSER_NAME+x} ]; then ./manage.py shell --no-startup --no-imports --interface python \
SUPERUSER_NAME='admin' </opt/netbox/super_user.py
fi
if [ -z ${SUPERUSER_EMAIL+x} ]; then
SUPERUSER_EMAIL='admin@example.com'
fi
if [ -f "/run/secrets/superuser_password" ]; then
SUPERUSER_PASSWORD="$(</run/secrets/superuser_password)"
elif [ -z ${SUPERUSER_PASSWORD+x} ]; then
SUPERUSER_PASSWORD='admin'
fi
if [ -f "/run/secrets/superuser_api_token" ]; then
SUPERUSER_API_TOKEN="$(</run/secrets/superuser_api_token)"
elif [ -z ${SUPERUSER_API_TOKEN+x} ]; then
SUPERUSER_API_TOKEN='0123456789abcdef0123456789abcdef01234567'
fi
./manage.py shell --interface python < /opt/netbox/super_user.py
fi fi
echo "✅ Initialisation is done." echo "✅ Initialisation is done."

View file

@ -1,12 +1,28 @@
from os import environ from os import environ
from users.models import Token, User
from users.choices import TokenVersionChoices
from django.conf import settings
su_name = environ.get("SUPERUSER_NAME") from django.conf import settings
su_email = environ.get("SUPERUSER_EMAIL") from users.choices import TokenVersionChoices
su_password = environ.get("SUPERUSER_PASSWORD") from users.models import Token, User
su_api_token = environ.get("SUPERUSER_API_TOKEN")
# Read secret from file
def _read_secret(secret_name: str, default: str | None = None) -> str | None:
try:
f = open("/run/secrets/" + secret_name, "r", encoding="utf-8")
except EnvironmentError:
return default
else:
with f:
return f.readline().strip()
su_name = environ.get("SUPERUSER_NAME", "admin")
su_email = environ.get("SUPERUSER_EMAIL", "admin@example.com")
su_password = _read_secret("superuser_password", environ.get("SUPERUSER_PASSWORD", "admin"))
su_api_token = _read_secret(
"superuser_api_token",
environ.get("SUPERUSER_API_TOKEN", "0123456789abcdef0123456789abcdef01234567"),
)
if not User.objects.filter(username=su_name): if not User.objects.filter(username=su_name):
u = User.objects.create_superuser(su_name, su_email, su_password) u = User.objects.create_superuser(su_name, su_email, su_password)
@ -15,8 +31,6 @@ if not User.objects.filter(username=su_name):
print("⚠️ No API token will be created as API_TOKEN_PEPPERS is not set") print("⚠️ No API token will be created as API_TOKEN_PEPPERS is not set")
msg = f"💡 Superuser Username: {su_name}, E-Mail: {su_email}" msg = f"💡 Superuser Username: {su_name}, E-Mail: {su_email}"
else: else:
t = Token.objects.create( t = Token.objects.create(user=u, token=su_api_token, version=TokenVersionChoices.V2)
user=u, token=su_api_token, version=TokenVersionChoices.V2
)
msg = f"💡 Superuser Username: {su_name}, E-Mail: {su_email}, API Token: {t} (use with '{t.get_auth_header_prefix()}<Your token>')" msg = f"💡 Superuser Username: {su_name}, E-Mail: {su_email}, API Token: {t} (use with '{t.get_auth_header_prefix()}<Your token>')"
print(msg) print(msg)

View file

@ -1,7 +1,7 @@
django-auth-ldap==5.3.0 django-auth-ldap==5.3.0
dulwich==0.25.0 dulwich==0.25.0
granian[uvloop]==2.6.0 granian[uvloop]==2.6.1
python3-saml==1.16.0 python3-saml==1.16.0
--no-binary lxml --no-binary lxml
--no-binary xmlsec --no-binary xmlsec
sentry-sdk[django]==2.48.0 sentry-sdk[django]==2.49.0