summaryrefslogtreecommitdiff
path: root/mailman/mklist.pl
blob: e1c2d069eb281b5a384d37f3b7cfa3676d692b43 (plain)
  1. #!/usr/bin/perl
  2. # TODO: derive listname from subjectprefix (which allows space and [])
  3. use warnings;
  4. our ($listname, $listdesc, $listhost, $senders, $senderfilter, $listowner, $moderators);
  5. # Load optional config
  6. my $config_file_addon_org = "/etc/local-ORG/mailman/mklist.conf";
  7. if ( -f $config_file_addon_org ) {
  8. do $config_file_addon_org
  9. or die "Error in config file $config_file_addon_org: $@";
  10. } else {
  11. warn "Ignoring non-existing file $config_file_addon_org";
  12. }
  13. $listname = $ENV{'LISTNAME'} or die "LISTNAME missing";
  14. $listdesc = $ENV{'LISTDESC'} or die "LISTDESC missing";
  15. $listhost = $ENV{'LISTHOST'} or die "LISTHOST missing";
  16. $senders = $ENV{'SENDERS'} or die "SENDERS missing";
  17. $senderfilters = $ENV{'SENDERFILTER'} || $ENV{'SENDERFILTERS'} || ''
  18. or warn "Ignoring missing SENDERFILTER(S)";
  19. $listowners = $ENV{'LISTOWNER'} || $ENV{'LISTOWNERS'}
  20. or die "LISTOWNER(S) missing";
  21. $moderators = $ENV{'MODERATORS'} || '';
  22. while (<>) {
  23. # Replace keywords - except in comments
  24. s/^([^#]*)LISTNAME/$1$listname/g;
  25. s/^([^#]*)LISTDESC/$1$listdesc/g;
  26. s/^([^#]*)LISTHOST/$1$listhost/g if ($listhost);
  27. s/^([^#]*)LISTHOST/#$1/g unless ($listhost);
  28. s/^([^#]*)SENDERS/$1$senders/g;
  29. s/^([^#]*)SENDERFILTERS/$1$senderfilters/g;
  30. s/^([^#]*)LISTOWNERS/$1$listowners/g;
  31. s/^([^#]*)MODERATORS/$1$moderators/g;
  32. print;
  33. }
  34. 1;