From 0cc32e7ed798a0394c6ec3ed6661f1b1f1f8f732 Mon Sep 17 00:00:00 2001 From: Chris Nagy Date: Sat, 10 Apr 2021 13:47:31 +0200 Subject: [PATCH] Extend docs with superuser --- docs/configuration.rst | 24 +++++++++++++++++++ .../management/commands/manage_superuser.py | 5 +++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/docs/configuration.rst b/docs/configuration.rst index 48b09213d..3534750b1 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -177,6 +177,30 @@ PAPERLESS_AUTO_LOGIN_USERNAME= Defaults to none, which disables this feature. +PAPERLESS_ADMIN_USER= + If this environment variable is specified, Paperless automatically creates + a superuser with the provided username at start. This is useful in cases + where you can not run the `create-superuser` command seperately, such as Kubernetes + or AWS ECS. + + Requires `PAPERLESS_ADMIN_PASSWORD` to be set. + + .. note:: + + This will not change an existing [super]user's password, nor will + it recreate a user that already exists. You can leave this throughout + the lifecycle of the containers. + +PAPERLESS_ADMIN_MAIL= + (Optional) Specify superuser email address. Only used when + `PAPERLESS_ADMIN_USER` is set. + + Defaults to ``root@localhost``. + +PAPERLESS_ADMIN_PASSWORD= + Only used when `PAPERLESS_ADMIN_USER` is set. + This will be the password of the automatically created superuser. + PAPERLESS_COOKIE_PREFIX= Specify a prefix that is added to the cookies used by paperless to identify diff --git a/src/documents/management/commands/manage_superuser.py b/src/documents/management/commands/manage_superuser.py index 3c5341cb3..ee3fbc8ef 100644 --- a/src/documents/management/commands/manage_superuser.py +++ b/src/documents/management/commands/manage_superuser.py @@ -26,5 +26,8 @@ class Command(BaseCommand): # Create superuser based on env variables User.objects.create_superuser(PAPERLESS_ADMIN_USER, PAPERLESS_ADMIN_MAIL, PAPERLESS_ADMIN_PASSWORD) self.stdout.write(f'Created superuser "{PAPERLESS_ADMIN_USER}" with provided password.') + else: + self.stdout.write(f'Did not create superuser "{PAPERLESS_ADMIN_USER}".') + self.stdout.write('Make sure you specified "PAPERLESS_ADMIN_PASSWORD" in your "docker-compose.env" file.') except Exception as error: - self.stdout.write(f'Exception occured while managing superuser: {error}') \ No newline at end of file + self.stdout.write(f'Exception occured while creating superuser: {error}') \ No newline at end of file