usr bin perl -w use strict use Getopt Long use MIME Base64 my proxyhos

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/perl -w
use strict;
use Getopt::Long;
use MIME::Base64;
my $proxyhost = "";
my $counter = 0;
my $roles = "";
my $units= "";
my $outfile= "";
GetOptions (
'roles=s' => \$roles,
'units=s' => \$units,
'outfile=s' => \$outfile
);
open (ROLES, $roles);
open (UNITS, $units);
while (my $lineRole = <ROLES>) {
while (my $lineUnit = <UNITS>) {
# empty string for MIME encoder so it won't add a new line at the end.
my $eol = "";
my @array = split(/\t/, $lineRole);
my @dssDetails = split(/\t/, $lineUnit);
my $schule = $dssDetails[1];
my $postalCode = $dssDetails[3];
my $state = encode_base64('Baden-W├╝rttemberg', $eol);
my $street = "";
if ( $dssDetails[2] ) {
my $street = encode_base64($dssDetails[2], $eol);
}
my $locality = "";
if ( $dssDetails[4] ) {
my $locality = encode_base64($dssDetails[4], $eol);
}
my ($localpart, $domainpart) = split(/@/,$array[2]);
$domainpart =~ /^0(\d+)\./ or warn "WARNING: can't parse $domainpart\n"; my $nr = $1;
my $mail0 = lc($array[0]);
my $mail1 = lc($array[2]);
my $maildrop1 = lc($array[3]);
my $maildrop2 = "";
my $maildrop3 = "";
if ($array[4]) { my $maildrop2 = lc($array[4]); }
if ($array[5]) { my $maildrop3 = lc($array[5]); }
my $userPassword = encode_base64($array[1], $eol);
my $sn = ucfirst($localpart);
print "dn: cn=$localpart,ou=$1,ou=people,dc=schule,dc=bwl,dc=de\n";
print "changetype: add\n";
print "objectClass: inetOrgPerson\n";
print "objectClass: organizationalPerson\n";
print "objectClass: person\n";
print "objectClass: top\n";
print "objectClass: simpleSecurityObject\n";
print "objectClass: CourierMailAlias\n";
print "objectClass: dovecotProxy\n";
printf "cn: $localpart\n";
print "mail: $mail0\n";
print "mail: $mail1\n";
print "maildrop: $maildrop1\n";
if ( $maildrop2 ) {
print "maildrop: $maildrop2\n";
}
if ( $maildrop3 ) {
print "maildrop: $maildrop3\n";
}
print "sn: $sn\n";
print "displayName: $sn ($schule)\n";
print "uid: vmail\n";
print "uidNumber: 1000\n";
print "gidNumber: 1000\n";
print "homeDirectory: /srv/mail/$1/$localpart/\n";
print "userPassword:: $userPassword\n";
print "street:: $street\n";
print "postalCode: $postalCode\n";
if ( $locality ) {
print "l:: $locality\n";
}
print "st:: $state\n";
print "proxy: 1\n";
print "proxyUser: $mail0*proxymaster\n";
print "proxyPassword: Theabei7\n";
print "proxyHost: $proxyhost\n";
print "\n";
}
}
if ( $counter == 0 ) {
$proxyhost = '10.11.9.10';
} else {
$proxyhost = '10.11.9.20';
}