Make database settings configurable

This commit is contained in:
Julian Rother 2025-02-07 00:52:10 +01:00
parent b1798cf33f
commit b33fae4ccd
Signed by: julian
GPG key ID: C19B924C0CD13341
3 changed files with 31 additions and 14 deletions

View file

@ -15,6 +15,18 @@ mailman:
change_pw: True change_pw: True
ldap: False ldap: False
session_timeout: 3600 session_timeout: 3600
db:
ENGINE: django.db.backends.sqlite3
NAME: /var/lib/mailman3/web/mailman3web.db
USER: ''
PASSWORD: ''
HOST: ''
PORT: ''
OPTIONS: {}
db:
class: mailman.database.sqlite.SQLiteDatabase
url: 'sqlite:///$DATA_DIR/mailman.db'
debug: 'no'
archiver: archiver:
key: "{{ lookup('password', '/dev/null length=128') }}" key: "{{ lookup('password', '/dev/null length=128') }}"
list_defaults: list_defaults:

View file

@ -40,7 +40,9 @@ MIDDLEWARE = (
{% if mailman.web.remote_user %} {% if mailman.web.remote_user %}
'django.contrib.auth.middleware.PersistentRemoteUserMiddleware', 'django.contrib.auth.middleware.PersistentRemoteUserMiddleware',
{% endif %} {% endif %}
{% if mailman.web.ldap %}
'postorius_ldap_membership_management.middleware.SessionTimeoutMiddleware', 'postorius_ldap_membership_management.middleware.SessionTimeoutMiddleware',
{% endif %}
) )
# Application definition # Application definition
@ -90,29 +92,30 @@ AUTHENTICATION_BACKENDS = (
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases # https://docs.djangoproject.com/en/1.8/ref/settings/#databases
DATABASES = { DATABASES = {
'default': { 'default': {{ mailman.web.db|pprint|indent(15) }}
#{
# Use 'sqlite3', 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. # Use 'sqlite3', 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'ENGINE': 'django.db.backends.sqlite3', #'ENGINE': 'django.db.backends.sqlite3',
#'ENGINE': 'django.db.backends.postgresql_psycopg2', #'ENGINE': 'django.db.backends.postgresql_psycopg2',
#'ENGINE': 'django.db.backends.mysql', #'ENGINE': 'django.db.backends.mysql',
# DB name or path to database file if using sqlite3. # DB name or path to database file if using sqlite3.
'NAME': '/var/lib/mailman3/web/mailman3web.db', #'NAME': '/var/lib/mailman3/web/mailman3web.db',
# The following settings are not used with sqlite3: # The following settings are not used with sqlite3:
'USER': '', #'USER': '',
'PASSWORD': '', #'PASSWORD': '',
# HOST: empty for localhost through domain sockets or '127.0.0.1' for # HOST: empty for localhost through domain sockets or '127.0.0.1' for
# localhost through TCP. # localhost through TCP.
'HOST': '', #'HOST': '',
# PORT: set to empty string for default. # PORT: set to empty string for default.
'PORT': '', #'PORT': '',
# OPTIONS: Extra parameters to use when connecting to the database. # OPTIONS: Extra parameters to use when connecting to the database.
'OPTIONS': { #'OPTIONS': {
# Set sql_mode to 'STRICT_TRANS_TABLES' for MySQL. See # Set sql_mode to 'STRICT_TRANS_TABLES' for MySQL. See
# https://docs.djangoproject.com/en/1.11/ref/ # https://docs.djangoproject.com/en/1.11/ref/
# databases/#setting-sql-mode # databases/#setting-sql-mode
#'init_command': "SET sql_mode='STRICT_TRANS_TABLES'", #'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
}, #},
} #}
} }

View file

@ -159,7 +159,7 @@ lock_file: $lock_dir/master.lck
[database] [database]
# The class implementing the IDatabase. # The class implementing the IDatabase.
class: mailman.database.sqlite.SQLiteDatabase #class: mailman.database.sqlite.SQLiteDatabase
#class: mailman.database.mysql.MySQLDatabase #class: mailman.database.mysql.MySQLDatabase
#class: mailman.database.postgresql.PostgreSQLDatabase #class: mailman.database.postgresql.PostgreSQLDatabase
@ -168,12 +168,14 @@ class: mailman.database.sqlite.SQLiteDatabase
# will store their data in this database, although external rosters may access # will store their data in this database, although external rosters may access
# other databases in their own way. This string supports standard # other databases in their own way. This string supports standard
# 'configuration' substitutions. # 'configuration' substitutions.
url: sqlite:///$DATA_DIR/mailman.db #url: sqlite:///$DATA_DIR/mailman.db
#url: mysql+pymysql://mailman3:mmpass@localhost/mailman3?charset=utf8&use_unicode=1 #url: mysql+pymysql://mailman3:mmpass@localhost/mailman3?charset=utf8&use_unicode=1
#url: postgres://mailman3:mmpass@localhost/mailman3 #url: postgres://mailman3:mmpass@localhost/mailman3
#debug: no
debug: no {% for key, value in mailman.db.items() %}
{{ key }}: {{ value }}
{% endfor %}
[logging.debian] [logging.debian]
# This defines various log settings. The options available are: # This defines various log settings. The options available are: