[Mailman-Users] one line command to change generic_nonmember_action
Steff Watkins
s.watkins at nhm.ac.uk
Mon Oct 18 11:46:20 CEST 2010
> -----Original Message-----
> On Behalf Of Syn, Joonho
> Sent: Friday, October 15, 2010 7:53 PM
> To: mailman-users at python.org
> Subject: [Mailman-Users] one line command to change
> generic_nonmember_action
>
> I'm writing a simplified mailman dashboard page for my
> company's internal use and one of the functions we want is to
> be able to toggle the generic_nonmember_action for any given
> list. Has anyone out there devised a one line command which
> will allow this?
Hi,
I'm not sure if there is a direct command that can do this but I've
been doing something similar lately. I had a setup of 20+ mailing lists
which had to be identical in a specialised configuration. Doing that by
the web interface filled me with dread so I started looking around and
found the mailman utility 'bin/config_list'.
This brilliant (imnsho!) utility allows you to either dump out a list's
configuration in plain text or read in a list's configuration, again in
plain text.
Let's see you have a list called SomeList. You can dump out the entire
configuration (not the members list, just the list's functional
settings) by typing:
> cd ~mailman
> bin/config_list -o - SomeList
This will dump to screen ( -o - ) the configuration of SomeList.
It's just a minor logical step to do
bin/config_list -o /usr/tmp/somelist-conf.txt SomeList
Which dumps the config into a file /usr/tmp/somelist-conf.txt
If you were to look at that file you'd find a section like this:
======
# When a post from a non-member is received, the message's sender is
# matched against the list of explicitly <a
# href="?VARHELP=privacy/sender/accept_these_nonmembers" >accepted,
# held, <a href="?VARHELP=privacy/sender/reject_these_nonmembers"
# >rejected (bounced), and <a
# href="?VARHELP=privacy/sender/discard_these_nonmembers" >discarded
# addresses. If no match is found, then this action is taken.
#
# legal values are:
# 0 = "Accept"
# 1 = "Hold"
# 2 = "Reject"
# 3 = "Discard"
generic_nonmember_action = 1
=====
You could either replace the value at the end of the line, or just swap
in a whole new line.
Then save the text file and read the configuration BACK to the list:
bin/config_list -i /usr/tmp/somelist-conf.txt SomeList
Note the change from '-o' (output) to '-i' (input).
It would be easily possible to pipe these commands together, maybe using
sed as the output=>input parser.
So something like,
bin/config_list -o - SomeList | /usr/bin/sed -f swapscript - |
bin/config_list -i - SomeList
Where 'swapscript' is a simple script to detect the
"generic_nonmember_action = 1" line and change it as you want.
Of course there's probably a simpler/better way of doing this but it
should work.
Regards,
S Watkins
---------------
Steff Watkins Natural History Museum, Cromwell
Road, London, SW7 5BD
Systems programmer Email: s.watkins at nhm.ac.uk
Systems Team Phone: +44 (0)20 7942 6000 opt 2
========
Many were increasingly of the opinion that they'd all made a big mistake
in coming down from the trees in the first place. And some said that
even the trees had been a bad move, and that no one should ever have
left the oceans. - HHGTTG
More information about the Mailman-Users
mailing list