Newer
Older
==============
Mailman3 tools
==============
This is a collection of MM3 tools to aid in daily administration of
Mailman3 (MM3) installations. Main goal was not to replicate existing
functionality but mainly augument existing toolkit with missing
functions.
.. ..contents:: Table of contents
:depth: 2
overall this toolkit is aimed at Docker-based mailman installations
using maxking's docker-compose project.
Easiest way to use those tools is to mount them inside mailman-web container
which already contains mailmanclient library and is running::
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
mailman-web:
image: maxking/mailman-web:0.1.7
container_name: mailman-web
...
volumes:
...
- $MAILMAN_WEB_DIR:/opt/mailman-web-data
- /opt/Mailman-tools:/opt/mailman-tools
...
this way tools are accessible from host environment via "docker exec" or
"docker-compose exec" invocations::
$ docker exec -it mailman-web python /opt/mailman-tools/list_stats.py --all > stats.json
Tools
=====
list_stats.py
-------------
obtain list statistics::
"mylist": {
"owners": 2,
"messages_held": 0,
"members": 7,
"list_fqdn_name": "mylist@lists.stanford.edu",
"last_digest": "2018-02-09T19:09:55.256954",
"nonmembers": 26,
"subscription_requests": 0,
"last_post": "2017-10-20T16:34:20.959539",
"moderators": 3
}
One can use jq to format output into something more concise::
$ docker exec -it mailman-web python /opt/mailman-tools/list_stats.py --all > stats.json
$ jq -cr 'to_entries[]| { (.key): {"held": (.value | .messages_held), "requests": (.value | .subscription_requests)} }' stats.json
manage_list.py
==============
this is the command-line interface for interaction with mailing list
operational functions: moderate requests/messages.
this tool utilizes following subcommand structure:
* held
* list
* approve
* reject
* discard
* delete
* defer
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
* list
* approve
* discard
* defer
for example moderate messages::
$ LIST_NAME=mylist@lists.stanford.edu
$ docker exec -it mailman-web python /opt/mailman-tools/manage_list.py $LIST_NAME held list > held.json
$ jq -r .[].request_id held.json # print all request_id's
$ docker exec -it mailman-web python /opt/mailman-tools/manage_list.py $LIST_NAME held discard --id=1234
subscription request moderation is handled in a similar fashion::
$ LIST_NAME=mylist@lists.stanford.edu
$ docker exec -it mailman-web python /opt/mailman-tools/manage_list.py $LIST_NAME requests list > requests.json
$ jq -r .[].token requests.json # print all tokens currently active
$ docker exec -it mailman-web python /opt/mailman-tools/manage_list.py $LIST_NAME requests discard --token=abcd123xyz
manage_settings.py
==================
this script helps to dump/restore/update list settings::
$ LIST_NAME=mylist@lists.stanford.edu
$ docker exec -i mailman-web python /opt/mailman-tools/manage_settings.py --dump $LIST_NAME > /${LIST_NAME}.json
$ vi ${LIST_NAME}.json
...edit out all the fields that you do not intend to modify
...and leave only ones that you want modify
$ cat %{LIST_NAME}.json | docker exec -t mailman-web python /opt/mailman-tools/manage_settings.py --update $LIST_NAME
$ # Or simply update settings right from CLI:
$ docker exec -t mailman-web python /opt/mailman-tools/manage_settings.py --set autoresponse_request_text="your request awaits approval" $LIST_NAME
manage_users.py (WIP)
=====================
dump/restore User subscriptions for specific mailing list. It's not complete yet
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
member_settings.py
==================
dump member subscription preferences for specified mailing list::
$ LIST_NAME=mylist@lists.stanford.edu
$ docker exec -t mailman-web python /opt/mailman-tools/member_settings.py --member=me@stanford.edu --member=him@stanford.edu $LIST_NAME
remove_user.py
==============
unsubscribes users from ML::
$ LIST_NAME=mylist@lists.stanford.edu
$ docker exec -t mailman-web python /opt/mailman-tools/remove_user.py --member=me@stanford.edu --member=him@stanford.edu $LIST_NAME
stats2omd.py
============
Helper script for processing bulk list stats (produced by list_stats.py) into
OMD (Check_mk) digestable format::
$ docker-compose -f mailman-docker-compose.yml exec -T mailman-web python /opt/mailman-tools/list_stats.py > stats.json
$ python stats2omd.py < stats.json
note that one doesn't have to run it within container as it doesn't use
any of the mailman APIs it's just a post-processing tool
sync_users.py
=============
synchronize list subscribers with a given list::
$ LIST_NAME=mylist@lists.stanford.edu
$ cat desired_member_list | docker exec -i mailman-web python /opt/mailman-tools/sync_users.py $LIST_NAME
this will remove users that are not in specified member list file and add the ones
that are.