Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Extend docs with superuser

Chris Nagy0cc32e7ed798
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=<username>
Defaults to none, which disables this feature.
+PAPERLESS_ADMIN_USER=<username>
+ 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=<email>
+ (Optional) Specify superuser email address. Only used when
+ `PAPERLESS_ADMIN_USER` is set.
+
+ Defaults to ``root@localhost``.
+
+PAPERLESS_ADMIN_PASSWORD=<password>
+ Only used when `PAPERLESS_ADMIN_USER` is set.
+ This will be the password of the automatically created superuser.
+
PAPERLESS_COOKIE_PREFIX=<str>
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