--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/split Fri Nov 04 06:29:26 2005 +0000
@@ -0,0 +1,105 @@
+#! /usr/bin/perl
+# © 2005 Heiko Schlittermann <hs@schlittermannn.de>
+# $Id$
+# $URL$
+#
+# Einlesen von Schubis mail.csv und aufteilen in fetchmailrc/users/aliases
+# zur bequemen Weiterverarbeitung
+my $USAGE = <<'#';
+Usage: {{ME}} [options] ...
+ --fetchmailrc=s Name of the fetchmailrc file [{{$::Cf->fetchmailrc}}]
+ --users=s Name of the fetchmailrc file [{{$::Cf->users}}]
+ --aliases=s Name of the fetchmailrc file [{{$::Cf->aliases}}]
+ --help
+
+ Hint: use '/dev/null' as file name to supress the generation
+ $Id$
+#
+
+
+use strict;
+use warnings;
+use AppConfig;
+use File::Basename;
+use IO::File;
+
+use constant ME => basename $0;
+
+use constant CONFIG => (
+ { CASE => 1 },
+ fetchmailrc => { DEFAULT => "fetchmailrc", ARGS => "=s" },
+ users => { DEFAULT => "users", ARGS => "=s" },
+ aliases => { DEFAULT => "aliases", ARGS => "=s" },
+ help => { DEFAULT => 0, ARGS => "!" }
+
+);
+
+$::Cf = new AppConfig CONFIG;
+$::Cf->getopt(\@ARGV);
+
+if ($::Cf->help) {
+ $USAGE =~ s/{{(.*?)}}/eval $1/eg;
+ print $USAGE;
+ exit;
+}
+
+
+
+MAIN: {
+ our $Cf;
+ my %groups;
+
+ my $fetchmailrc = new IO::File $_ = $Cf->fetchmailrc, "w" or die ME.": Can't open >$_: $!\n"
+ if $Cf->fetchmailrc;
+ my $users = new IO::File $_ = $Cf->users, "w" or die ME.": Can't open >$_: $!\n"
+ if $Cf->users;
+
+
+ while (<>) {
+ $. == 1 and next;
+ s/\s*$//;
+ my ($mailto, $popbox, $poppass, $intern, $group, $imapuser, $imappass)
+ = split /;/;
+
+ # externes Postfach?
+ if ($fetchmailrc and $popbox) {
+ print $fetchmailrc "user \"$popbox\" with password \"$poppass\" is $mailto here\n";
+ }
+
+ # realser Nutzer?
+ if ($mailto =~ /^\Q$imapuser\E/) {
+ my ($first, $last) = split /\./, $imapuser;
+ $last or $last = $first, $first = "";
+ print $users join(":",
+ $imapuser,
+ $imappass,
+ join(" ", $first ? ucfirst($first) : (), ucfirst($last)),
+ join(",", $imapuser, $last, $first ? substr($first, 0, 1) . ".$last" : ()),
+ "\n");
+ } else {
+ $mailto =~ s/\@.*//;
+ push @{$groups{$mailto}}, $imapuser;
+ }
+ }
+
+ if ($Cf->aliases) {
+ my $aliases = new IO::File $_ = $Cf->aliases, "w" or die ME . ": Can't open >$_: $!\n";
+ print $aliases map { "$_: ". join(", ", @{$groups{$_}}). "\n" } sort keys %groups;
+ }
+
+}
+
+__END__
+
+mailadresse;popmailbox;popmailpw;intern;intern-gruppe;imapaccount;imappw
+annika.henze@vw-audi-dresden-reick.de;;;intern;;annika.henze;ahenze
+isabell.zeiske@vw-audi-dresden-reick.de;;;intern;;isabell.zeiske;izeiske
+julia.micheel@vw-audi-dresden-reick.de;;;intern;;jilia.micheel;jmicheel
+mandy.stranz@vw-audi-dresden-reick.de;;;intern;;mandy.stranz;mstranz
+susann.kolodziejczyk@vw-audi-dresden-reick.de;;;intern;;susann.kolodziejczyk;skolo
+renate.feurich@vw-audi-dresden-reick.de;;;intern;;renate.feurich;rfeurich
+rwks01@vw-audi-dresden-reick.de;;;intern;;rwks01;rwks01
+rwks02@vw-audi-dresden-reick.de;;;intern;;rwks02;rwks02
+rwks03@vw-audi-dresden-reick.de;;;intern;;rwks03;rwks03
+
+# vim:sts=4 sw=4 aw ai sm: