[PYTHON] Change batch settings with Mailman's withlist command

It may be necessary to change the settings of multiple mailing lists, such as when the archive of the mailing list is deleted due to a change in the operation policy of the organization, but it is necessary to change the settings of each mailing list from the Web management screen one by one. It Is difficult.

In such cases, Mailman can use the withlist command.

First, check that you can change the settings for one mailing list. Use the dumpdb command to check the current settings saved in binary format.

# cd /var/lib/mailman
# bin/dumpdb -p lists/mlname/config.pck | grep archive
    'archive': True,
    'archive_private': 0,
    'archive_volume_frequency': 1,

Archiving is currently enabled on the mlname mailing list. Change this to disabled.

As a preparation, prepare the processing of setting change with a Python script. Since the mailing list object is passed as an argument, change the setting between Lock () and Save ().

disable_archive.py


def disable_archive(mlist):
    mlist.Lock()
    mlist.archive = False
    mlist.Save()

Apply the process written in the Python script with the withlist command.

# withlist -r disable_archive mlname
Importing disable_archive...
Running disable_archive.disable_archive()...
Loading list mlname (unlocked)
Unlocking (but not saving) list: mlname
Finalizing

You can now change the settings. I will check it just in case.

# bin/dumpdb -p lists/mlname/config.pck | grep archive
    'archive': False,
    'archive_private': 0,
    'archive_volume_frequency': 1,

Once you've confirmed that you can change the settings, use the "-a" option instead of the mailing list name to apply it to all mailing lists.

# withlist -r disable_archive -a
Importing disable_archive...
Running disable_archive.disable_archive()...
Loading list ml1 (unlocked)
Loading list ml2 (unlocked)
Loading list ml3 (unlocked)
(abridgement)
Loading list ml99 (unlocked)

The settings have now been changed on all mailing lists. To be on the safe side, sample some properly and make sure the settings have changed.

# bin/dumpdb -p lists/ml1/config.pck | grep archive
    'archive': False,
    'archive_private': 0,
    'archive_volume_frequency': 1,

It seems to be okay.

Mailman is usually operated from the management screen of the Web, but if you can operate it from the command line, it will be easier to operate at once.

Recommended Posts

Change batch settings with Mailman's withlist command
Change retry settings with boto3
change vim settings
Change IP settings to ACL of conoha with python
File name batch change
Django command completion settings
Try Juniper JUNOS PyEz (python library) Memo 3 ~ Change settings with PyEz ~
Change node settings in supernodes with SPSS Modeler Python scripts