diff --git a/README.md b/README.md index ab3c52af..92d53cc0 100644 --- a/README.md +++ b/README.md @@ -196,7 +196,7 @@ These are the settings that you MUST change before deploying: (with SITE_ID=1). - `HYPERKITTY_API_KEY`: Hyperkitty's API Key, should be set to the same value - as set for the mailman-core. + as set for the mailman-core. (Not needed in case of Postorius-only version.) - `MAILMAN_ADMIN_USER`: The username for the admin user to be created by default. @@ -234,7 +234,7 @@ For more details on how to configure this image, please look at These are the variables that you MUST change before deploying: - `HYPERKITTY_API_KEY`: Hyperkitty's API Key, should be set to the same value as - set for the mailman-web. + set for the mailman-web. Skip the variable in case of non-Hyperkitty deployment. - `DATABASE_URL`: URL of the type `driver://user:password@hostname:port/databasename` for the django to use. If diff --git a/core/docker-entrypoint.sh b/core/docker-entrypoint.sh index c0d8d386..9a4d0d75 100755 --- a/core/docker-entrypoint.sh +++ b/core/docker-entrypoint.sh @@ -125,11 +125,6 @@ admin_user: $MAILMAN_REST_USER admin_pass: $MAILMAN_REST_PASSWORD configuration: /etc/gunicorn.cfg -[archiver.hyperkitty] -class: mailman_hyperkitty.Archiver -enable: yes -configuration: /etc/mailman-hyperkitty.cfg - EOF # Generate a basic gunicorn.cfg. @@ -197,11 +192,17 @@ then cat /opt/mailman/gunicorn-extra.cfg > /etc/gunicorn.cfg fi -if [[ ! -v HYPERKITTY_API_KEY ]]; then - echo "HYPERKITTY_API_KEY not defined, please set this environment variable..." - echo "exiting..." - exit 1 -fi +if [[ -v HYPERKITTY_API_KEY ]]; then + +echo "HYPERKITTY_API_KEY found, setting up HyperKitty archiver..." + +cat >> /etc/mailman.cfg << EOF +[archiver.hyperkitty] +class: mailman_hyperkitty.Archiver +enable: yes +configuration: /etc/mailman-hyperkitty.cfg + +EOF if [[ ! -v HYPERKITTY_URL ]]; then echo "HYPERKITTY_URL not set, using the default value of http://mailman-web:8000/hyperkitty" @@ -215,6 +216,12 @@ base_url: $HYPERKITTY_URL api_key: $HYPERKITTY_API_KEY EOF +else + +echo "HYPERKITTY_API_KEY not defined, skipping HyperKitty setup..." + +fi + # Generate the LMTP files for postfix if needed. mailman aliases diff --git a/docker-compose-postorius.yaml b/docker-compose-postorius.yaml index c7122c0a..c9828ff1 100644 --- a/docker-compose-postorius.yaml +++ b/docker-compose-postorius.yaml @@ -16,7 +16,6 @@ services: - DATABASE_URL=postgres://mailman:mailmanpass@database/mailmandb - DATABASE_TYPE=postgres - DATABASE_CLASS=mailman.database.postgresql.PostgreSQLDatabase - - HYPERKITTY_API_KEY=someapikey networks: mailman: ipv4_address: 172.19.199.2 @@ -35,7 +34,6 @@ services: environment: - DATABASE_TYPE=postgres - DATABASE_URL=postgres://mailman:mailmanpass@database/mailmandb - - HYPERKITTY_API_KEY=someapikey - SECRET_KEY=ksjdbaksdba - UWSGI_STATIC_MAP=/static=/opt/mailman-web-data/static networks: diff --git a/postorius/mailman-web/settings.py b/postorius/mailman-web/settings.py index 38177bb1..3d9f8156 100644 --- a/postorius/mailman-web/settings.py +++ b/postorius/mailman-web/settings.py @@ -27,7 +27,6 @@ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os -import socket import dj_database_url import sys @@ -57,8 +56,6 @@ os.environ.get('DJANGO_ALLOWED_HOSTS'), ] -# Try to get the address of Mailman Core automatically. - # Mailman API credentials MAILMAN_REST_API_URL = os.environ.get('MAILMAN_REST_URL', 'http://mailman-core:8001') MAILMAN_REST_API_USER = os.environ.get('MAILMAN_REST_USER', 'restadmin') @@ -67,7 +64,7 @@ # Application definition -INSTALLED_APPS = ( +INSTALLED_APPS = [ 'postorius', 'django_mailman3', # Uncomment the next line to enable the admin: @@ -89,7 +86,7 @@ 'allauth.socialaccount.providers.github', 'allauth.socialaccount.providers.gitlab', 'allauth.socialaccount.providers.google', -) +] MIDDLEWARE = ( 'django.contrib.sessions.middleware.SessionMiddleware', @@ -213,9 +210,10 @@ EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = os.environ.get('SMTP_HOST', '172.19.199.1') EMAIL_PORT = os.environ.get('SMTP_PORT', 25) -EMAIL_HOST_USER = '' -EMAIL_HOST_PASSWORD = '' -EMAIL_USE_TLS = False +EMAIL_HOST_USER = os.environ.get('SMTP_HOST_USER', '') +EMAIL_HOST_PASSWORD = os.environ.get('SMTP_HOST_PASSWORD', '') +EMAIL_USE_TLS = os.environ.get('SMTP_USE_TLS', False) + # Compatibility with Bootstrap 3 from django.contrib.messages import constants as messages # flake8: noqa @@ -339,6 +337,7 @@ if os.environ.get('LOG_TO_CONSOLE') == 'yes': LOGGING['loggers']['django']['handlers'].append('console') LOGGING['loggers']['django.request']['handlers'].append('console') +POSTORIUS_TEMPLATE_BASE_URL = os.environ.get('POSTORIUS_TEMPLATE_BASE_URL', 'http://mailman-web:8000') try: from settings_local import *