Changeset 328:73e179721396

Show
Ignore:
Timestamp:
08/22/11 16:55:25 (9 months ago)
Author:
Anselm Lingnau <anselm@…>
Branch:
default
Message:

Various changes to pl-init.
pl-init will now add the list owner to the list as a subscriber with admin
privileges. This is mainly to make life easier for deployments of many lists
with Project Guinevere.

Also, the --config=... command line option was changed to read configuration
parameter assignments from a file whose name is given as the argument.
Individual paramter assignments may now be passed as additional command-line
arguments after the list owner address.

Files:
2 modified

Legend:

Unmodified
Added
Removed
  • bin/pl-init

    r303 r328  
    77=head1 SYNOPSIS 
    88 
    9  pl-init [-v?] [--clone=otherlist] [-config=CONFIG] ... 
     9 pl-init [-v?] [--clone=otherlist] [--config=FILE] ... 
    1010        [--[no]mailfilter] [--our-isp] [--verbose] 
    11           list@domain owner-address 
     11          list@domain owner-address key=value ... 
    1212 
    1313=head1 OVERVIEW 
    1414 
    15 The B<pl-init> command creates a new Lancelot mailing list with no 
    16 subscribers and a basic (if sensible) configuration. 
     15The B<pl-init> command creates a new Lancelot mailing list with 
     16a sensible (if basic) configuration. 
    1717 
    1818=head1 DESCRIPTION 
     
    2626the content of a system-wide defaults file (if available), (3) the 
    2727content of the user-specific defaults file F<$HOME/.pl/defaults.conf> 
    28 (if available), and (4) any configuration parameter assignments given 
    29 on the command line, in that order. Later settings override earlier 
    30 ones.  Between (3) and (4), the B<list.address> parameter is set to 
    31 I<list@domain>, the B<list.owneraddress> parameter is set to 
    32 I<owner-address>, and the B<list.name> parameter is set to the 
    33 local part of I<list@domain>, capitalised. 
     28(if available), (4) any files whose names are passed on the command line 
     29by means of the B<--config> option, and (5) any configuration parameter 
     30assignments given on the command line, in that order. Later settings 
     31override earlier ones.  Between (3) and (4), the B<list.address> parameter 
     32is set to I<list@domain>, the B<list.owneraddress> parameter is set to 
     33I<owner-address>, the B<list.ownername> parameter is set to the list 
     34owner's name if one is passed as part of I<owner-address>, and the 
     35B<list.name> parameter is set to the local part of I<list@domain>, 
     36capitalised. 
     37 
     38Any command-line parameters passed after I<owner-address> will be 
     39considered configuration parameter assignments in the sense of (5) above. 
     40Note that these are pre-parsed by the shell, and USE QUOTES IF YOUR 
     41CONFIGURATION PARAMETER ASSIGNMENTS CONTAIN WHITESPACE. 
    3442 
    3543If a list configuration is "cloned" from that of another list, that 
    3644list's configuration is copied to the new list after the defaults 
    37 files have been processed but before the command-line parameter 
    38 assignments take effect. This makes it possible to copy a list's 
    39 configuration "except for" some specific settings. The list and owner 
    40 addresses are set immediately before the command-line parameter 
    41 assignments are processed, so they will be correct for a "cloned" 
    42 list; you overwrite them from the command line at your own peril. 
     45files have been processed but before the configuration files and 
     46parameter assignments given on the command line take effect. 
     47This makes it possible to copy a list's configuration "except for" 
     48some specific settings. The list and owner addresses are set immediately 
     49before the command-line parameter assignments are processed, so they will 
     50be correct for a "cloned" list; you overwrite them from the command line 
     51at your own peril. 
     52 
     53The I<owner-address> will also be subscribed to the list as an 
     54administrator. If you'd rather not have this, add the configuration 
     55parameter 
     56 
     57  list.subscribeowner = 0 
     58 
     59to one of the default files or invoke B<pl-init> like 
     60 
     61  pl-init list@domain owner@domain list.subscribeowner=0 
     62 
    4363 
    4464=head1 OPTIONS 
     
    5272as the new list. 
    5373 
    54 =item B<--config>=I<key>=I<value> 
    55  
    56 Changes the list configuration parameter I<key> to I<value> (use 
    57 quotes if I<value> contains whitespace).  If B<--config> is used 
    58 together with B<--clone>, the changes take place after the 
    59 configuration has been cloned. There may be multiple B<--config> 
    60 options on the same command line. Configuration parameters may be 
    61 changed later using the B<pl-conf> command. 
    62  
    63 USE QUOTES IF YOUR VALUES CONTAIN WHITESPACE. 
     74=item B<--config>=I<file> 
     75 
     76Reads configuration parameter assignments from I<file>. Empty lines 
     77and comment lines (starting with "#") in I<file> will be ignored. 
     78 
     79If B<--config> is used together with B<--clone>, the changes take 
     80place after the configuration has been cloned. There may be multiple 
     81B<--config> options on the same command line. Configuration parameters 
     82may be changed later using the B<pl-conf> command. 
    6483 
    6584=item B<--mailfilter> 
     
    93112=head1 COPYRIGHT AND LICENSE 
    94113 
    95 Copyright 2004 by Anselm Lingnau. This program is free software; you 
     114Copyright 2004-11 by Anselm Lingnau. This program is free software; you 
    96115may redistribute it and/or modify it under the terms of the GNU 
    97116General Public License as published by the Free Software Foundation; 
     
    130149use Lancelot::Log qw/log/; 
    131150 
    132 my (%opts); 
     151my %opts; 
    133152 
    134153GetOptions(\%opts, -defaults, 
    135154           -argvmin => 2, "need list and owner address", 
    136            -argvmax => 2, "too many arguments", 
    137155           "our-isp?", "clone=", "config@", "mailfilter!"); 
    138156 
    139 my ($listaddr, $owneraddr) = @ARGV; 
    140 my (%options) = ( create => 1, ourisp => $opts{"our-isp"} ); 
     157my $listaddr = shift; 
     158my $owneraddr = (Email::Address->parse(shift))[0]; 
     159my $ownername = $owneraddr->phrase || $owneraddr->comment; 
     160 
     161my %options = ( create => 1, ourisp => $opts{"our-isp"} ); 
    141162 
    142163my $db = new Lancelot::DB $listaddr, \%options 
     
    146167 
    147168$db->set_config("list.address", $listaddr); 
    148 $db->set_config("list.owneraddress", $owneraddr); 
    149 my ($listname) = $listaddr; 
     169$db->set_config("list.owneraddress", $owneraddr->address); 
     170$db->set_config("list.ownername", $ownername) if $ownername; 
     171my $listname = $listaddr; 
    150172$listname =~ s/\@.*$//; 
    151173$db->set_config("list.name", ucfirst($listname)); 
    152174 
    153 $db->set_configs(@{$opts{config}}) if @{$opts{config}}; 
     175$db->set_configs_from_file($_, 0) foreach @{$opts{config}}; 
     176$db->set_configs(@ARGV) if @ARGV; 
    154177 
    155178if ($opts{"our-isp"} && !($opts{mailfilter} == 0)) { 
     
    165188        die "$0: couldn't create $mfname: $!\n"; 
    166189    } 
     190} else { 
     191    my $xlistaddr = $listaddr; 
     192    my $delim = $db->get_config("mail.delimiter"); 
     193    $xlistaddr =~ s/\@/${delim}ANYTHING\@/; 
     194    my $user = getpwuid($<); 
     195 
     196    print "Make sure that within your MTA setup, messages to\n\n"; 
     197    print "    $listaddr   as well as\n"; 
     198    print "    $xlistaddr\n\n"; 
     199    print "are piped into\n\n"; 
     200    print "    $Bin/pl-incoming --user $user $listaddr\n\n"; 
     201    print "Consult Project Lancelot's Deployment-HOWTO for details.\n"; 
     202} 
     203 
     204my $subscribe_owner = $db->get_config("list.subscribeowner"); 
     205if ($subscribe_owner) { 
     206    log "info", "subscribing owner address as list administrator"; 
     207    unless ($db->add_address($owneraddr, { admin => 1 })) { 
     208        log "err", "error subscribing $owneraddr\n"; 
     209    } 
    167210} 
    168211 
  • lib/Lancelot/ConfigItems.pm

    r326 r328  
    9898list.owneraddress|STR||Address of the list owner, for LIST+owner@DOMAIN 
    9999list.ownername|STR||Name of the list owner 
     100list.subscribeowner|BOOL|1|Subscribe list owner as administrator when list is created 
    100101mail.addheaders|STR||List of names of headers to be added to outgoing messages (put header values in »mail.header.NAME« variables) 
    101102mail.delimiter|STR|+|Character between list name and extensions (must match MTA setup)