summaryrefslogtreecommitdiff
path: root/mailman/mklist.pl
blob: c15d79932c5ebba9fa5c1cd8710e93d47e2b0201 (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);
  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 or die "Error in config file $config_file_addon_org: $@";
  9. } else {
  10. warn "Ignoring non-existing file $config_file_addon_org";
  11. }
  12. $listname ||= $ENV{'LISTNAME'} or die "LISTNAME missing";
  13. $listdesc ||= $ENV{'LISTDESC'} or die "LISTDESC missing";
  14. $listhost ||= $ENV{'LISTHOST'} or die "LISTHOST missing";
  15. $senders ||= $ENV{'SENDERS'} or die "SENDERS missing";
  16. $senderfilter ||= $ENV{'SENDERFILTER'} or die "SENDERFILTER missing";
  17. $listowner ||= $ENV{'LISTOWNER'} or die "LISTOWNER missing";
  18. while (<>) {
  19. # Replace keywords - except in comments
  20. s/^([^#]*)LISTNAME/$1$listname/g;
  21. s/^([^#]*)LISTDESC/$1$listdesc/g;
  22. s/^([^#]*)LISTHOST/$1$listhost/g if ($listhost);
  23. s/^([^#]*)LISTHOST/#$1/g unless ($listhost);
  24. s/^([^#]*)SENDERS/$1$senders/g;
  25. s/^([^#]*)SENDERFILTER/$1$senderfilter/g;
  26. s/^([^#]*)LISTOWNER/$1$listowner/g;
  27. print;
  28. }
  29. 1;