Apply common configuration changes to each mailing list
This commit is contained in:
parent
303ddc002c
commit
17e677aae0
@ -8,10 +8,52 @@ import argparse
|
|||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import tempfile
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
|
||||||
|
def config_list(mailman_bin: Path, mailing_list: str):
|
||||||
|
config_changes = """
|
||||||
|
# TODO: set real_name, moderator, subject prefix, and reply-to address
|
||||||
|
from_is_list = 1
|
||||||
|
anonymous_list = 1
|
||||||
|
first_strip_reply_to = 1
|
||||||
|
reply_goes_to_list = 2
|
||||||
|
|
||||||
|
# quiet member management
|
||||||
|
send_reminders = 0
|
||||||
|
send_welcome_msg = 0
|
||||||
|
send_goodbye_msg = 0
|
||||||
|
|
||||||
|
new_member_options = 272
|
||||||
|
advertised = 0
|
||||||
|
private_roster = 2 # only admins can view the roster
|
||||||
|
default_member_moderation = 1
|
||||||
|
|
||||||
|
generic_nonmember_action = 3 # discard non-member emails
|
||||||
|
forward_auto_discards = 0 # don't notify admin about discards
|
||||||
|
"""
|
||||||
|
|
||||||
|
with tempfile.NamedTemporaryFile("w", suffix=".py") as config_file:
|
||||||
|
config_file.write(config_changes)
|
||||||
|
config_file.flush()
|
||||||
|
output = subprocess.run(
|
||||||
|
[
|
||||||
|
mailman_bin / "config_list",
|
||||||
|
"--verbose",
|
||||||
|
"--inputfile",
|
||||||
|
config_file.name,
|
||||||
|
mailing_list,
|
||||||
|
],
|
||||||
|
encoding="ascii",
|
||||||
|
capture_output=True,
|
||||||
|
check=True,
|
||||||
|
)
|
||||||
|
for line in output.stdout.splitlines():
|
||||||
|
print(f"[Configuring {mailing_list}] {line}")
|
||||||
|
|
||||||
|
|
||||||
def sync_members(
|
def sync_members(
|
||||||
mailman_bin: Path, mailing_list: str, members: list[str], dry_run: bool
|
mailman_bin: Path, mailing_list: str, members: list[str], dry_run: bool
|
||||||
):
|
):
|
||||||
@ -55,6 +97,8 @@ def main(mailman_bin: Path, api: str, api_auth: str, list_suffix: str, dry_run:
|
|||||||
for name, members in certification_lists.items():
|
for name, members in certification_lists.items():
|
||||||
list_name = name + list_suffix
|
list_name = name + list_suffix
|
||||||
if list_name in existing_lists:
|
if list_name in existing_lists:
|
||||||
|
print(f"Configuring/syncing {list_name}...")
|
||||||
|
config_list(mailman_bin, list_name)
|
||||||
sync_members(mailman_bin, list_name, members, dry_run)
|
sync_members(mailman_bin, list_name, members, dry_run)
|
||||||
else:
|
else:
|
||||||
print(f"Skipping {list_name}, as it does not exist in Mailman")
|
print(f"Skipping {list_name}, as it does not exist in Mailman")
|
||||||
|
Loading…
Reference in New Issue
Block a user