diff options
Diffstat (limited to 'mailman/mklist.pl')
-rwxr-xr-x | mailman/mklist.pl | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/mailman/mklist.pl b/mailman/mklist.pl new file mode 100755 index 0000000..847234b --- /dev/null +++ b/mailman/mklist.pl @@ -0,0 +1,36 @@ +#!/usr/bin/perl + +# TODO: derive listname from subjectprefix (which allows space and []) + +use warnings; + +our ($listname, $listdesc, $listhost, $senders, $senderfilter, $listowner); + +# Load optional config +my $config_file_addon_org = "/etc/local-ORG/mailman/mklist.conf"; +if ( -f $config_file_addon_org ) { + do $config_file_addon_org or die "Error in config file $config_file_addon_org: $@"; +} else { + warn "Ignoring non-existing file $config_file_addon_org"; +} + +$listname ||= $ENV{'LISTNAME'} or die "LISTNAME missing"; +$listdesc ||= $ENV{'LISTDESC'} or die "LISTDESC missing"; +$listhost ||= $ENV{'LISTHOST'} or die "LISTHOST missing"; +$senders ||= $ENV{'SENDERS'} or die "SENDERS missing"; +$senderfilter ||= $ENV{'SENDERFILTER'} or die "SENDERFILTER missing"; +$listowner ||= $ENV{'LISTOWNER'} or die "LISTOWNER missing"; + +while (<>) { + # Replace keywords - execept in comments + s/^([^#]*)LISTNAME/$1$listname/g; + s/^([^#]*)LISTDESC/$1$listdesc/g; + s/^([^#]*)LISTHOST/$1$listhost/g; + s/^([^#]*)SENDERS/$1$senders/g; + s/^([^#]*)SENDERFILTER/$1$senderfilter/g; + s/^([^#]*)LISTOWNER/$1$listowner/g; + + print; +} + +1; |