system-config/playbooks/roles/mailman/files/mm_cfg_multihost.py
Clark Boylan 6c115cf29e Add support for Ubuntu Focal to our mailman ansible
This switch testing of lists.openstack.org to Focal and we make a CGI
env var update to accomodate newer mailman.

Specifically newer mailman's CGI scripts filter env vars that it will
pass through. We were setting MAILMAN_SITE_DIR to vhost our mailman
installs with apache2, but that doesn't pass the filter and is removed.
HOST is passed through so we update our scripts, apache vhost configs,
exim, and init scripts to use the HOST env var instead.

Change-Id: I5c8c70c219669e37b7b75a61001a2b7f7bb0bb6c
2021-09-13 09:10:00 -07:00

61 lines
2.2 KiB
Python

import os
import sys
if 'MAILMAN_SITE_DIR' not in os.environ and 'HOST' not in os.environ:
print("Please set MAILMAN_SITE_DIR or HOST")
# Exit 0 to avoid confusing the dpkg scripts
sys.exit(0)
site_dir = None
if 'MAILMAN_SITE_DIR' in os.environ:
site_dir = os.environ['MAILMAN_SITE_DIR']
elif 'HOST' in os.environ:
host = os.environ['HOST']
with open('/etc/mailman/sites') as f:
for line in f:
if line.startswith(host + ':'):
site_dir = line.split(':')[1].strip()
if not site_dir:
print("Site dir not found")
# Exit 0 to avoid confusing the dpkg scripts
sys.exit(0)
sys.path.insert(0, os.path.join(site_dir, 'etc'))
from mm_cfg_local import *
VAR_PREFIX = site_dir
# Useful directories
LIST_DATA_DIR = os.path.join(VAR_PREFIX, 'lists')
LOG_DIR = os.path.join(VAR_PREFIX, 'logs')
LOCK_DIR = os.path.join(VAR_PREFIX, 'locks')
DATA_DIR = os.path.join(VAR_PREFIX, 'data')
SPAM_DIR = os.path.join(VAR_PREFIX, 'spam')
WRAPPER_DIR = os.path.join(EXEC_PREFIX, 'mail')
BIN_DIR = os.path.join(PREFIX, 'bin')
SCRIPTS_DIR = os.path.join(PREFIX, 'scripts')
TEMPLATE_DIR = os.path.join(VAR_PREFIX, 'templates')
MESSAGES_DIR = os.path.join(PREFIX, 'messages')
PUBLIC_ARCHIVE_FILE_DIR = os.path.join(VAR_PREFIX, 'archives', 'public')
PRIVATE_ARCHIVE_FILE_DIR = os.path.join(VAR_PREFIX, 'archives', 'private')
# Directories used by the qrunner subsystem
QUEUE_DIR = os.path.join(VAR_PREFIX, 'qfiles')
INQUEUE_DIR = os.path.join(QUEUE_DIR, 'in')
OUTQUEUE_DIR = os.path.join(QUEUE_DIR, 'out')
CMDQUEUE_DIR = os.path.join(QUEUE_DIR, 'commands')
BOUNCEQUEUE_DIR = os.path.join(QUEUE_DIR, 'bounces')
NEWSQUEUE_DIR = os.path.join(QUEUE_DIR, 'news')
ARCHQUEUE_DIR = os.path.join(QUEUE_DIR, 'archive')
SHUNTQUEUE_DIR = os.path.join(QUEUE_DIR, 'shunt')
VIRGINQUEUE_DIR = os.path.join(QUEUE_DIR, 'virgin')
BADQUEUE_DIR = os.path.join(QUEUE_DIR, 'bad')
RETRYQUEUE_DIR = os.path.join(QUEUE_DIR, 'retry')
MAILDIR_DIR = os.path.join(QUEUE_DIR, 'maildir')
# Other useful files
PIDFILE = os.path.join(VAR_PREFIX, 'run', 'mailman.pid')
SITE_PW_FILE = os.path.join(DATA_DIR, 'adm.pw')
LISTCREATOR_PW_FILE = os.path.join(DATA_DIR, 'creator.pw')