summaryrefslogtreecommitdiff
path: root/mailman/mklist.pl
blob: c7870510cc77080cfb2f12835391eccadd90e4fd (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
  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. while (<>) {
  22. # Replace keywords - except in comments
  23. s/^([^#]*)LISTNAME/$1$listname/g;
  24. s/^([^#]*)LISTDESC/$1$listdesc/g;
  25. s/^([^#]*)LISTHOST/$1$listhost/g if ($listhost);
  26. s/^([^#]*)LISTHOST/#$1/g unless ($listhost);
  27. s/^([^#]*)SENDERS/$1$senders/g;
  28. s/^([^#]*)SENDERFILTERS/$1$senderfilters/g;
  29. s/^([^#]*)LISTOWNERS/$1$listowners/g;
  30. print;
  31. }
  32. 1;