summaryrefslogtreecommitdiff
path: root/src/mailman/config/config.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman/config/config.py')
-rw-r--r--src/mailman/config/config.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/mailman/config/config.py b/src/mailman/config/config.py
index 7249c6d92..74931c029 100644
--- a/src/mailman/config/config.py
+++ b/src/mailman/config/config.py
@@ -31,6 +31,7 @@ import os
import sys
from ConfigParser import SafeConfigParser
+from flufl.lock import Lock
from lazr.config import ConfigSchema, as_boolean
from pkg_resources import resource_filename, resource_stream, resource_string
from string import Template
@@ -50,6 +51,21 @@ from mailman.utilities.modules import call_name
SPACE = ' '
+MAILMAN_CFG_TEMPLATE = """\
+# AUTOMATICALLY GENERATED BY MAILMAN ON {}
+#
+# This is your GNU Mailman 3 configuration file. You can edit this file to
+# configure Mailman to your needs, and Mailman will never overwrite it.
+# Additional configuration information is (for now) available in the
+# schema.cfg file <http://tinyurl.com/cm5rtqe> and the base mailman.cfg file
+# <http://tinyurl.com/dx9b8eg>.
+#
+# For example, uncomment the following lines to run Mailman in developer mode.
+#
+# [devmode]
+# enabled: yes
+# recipient: your.address@your.domain"""
+
@implementer(IConfiguration)
@@ -211,6 +227,19 @@ class Configuration:
if self.create_paths:
for variable, directory in self.paths.items():
makedirs(directory)
+ # Avoid circular imports.
+ from mailman.utilities.datetime import now
+ # Create a mailman.cfg template file if it doesn't already exist.
+ # LBYL: <boo hiss>, but it's probably okay because the directories
+ # likely didn't exist before the above loop, and we'll create a
+ # temporary lock.
+ lock_file = os.path.join(self.LOCK_DIR, 'mailman-cfg.lck')
+ mailman_cfg = os.path.join(self.ETC_DIR, 'mailman.cfg')
+ with Lock(lock_file):
+ if not os.path.exists(mailman_cfg):
+ with open(mailman_cfg, 'w') as fp:
+ print(MAILMAN_CFG_TEMPLATE.format(
+ now().replace(microsecond=0)), file=fp)
@property
def runner_configs(self):