5 # The following exit codes are defined and MUST BE CONSISTENT with the
6 # error codes the library uses:
7 $MR_DBMS_ERR = 47836421;
10 $outfile = '/moira/dcm/mailhosts.out';
14 $dbh = DBI->connect("dbi:Oracle:moira", "moira", "moira")
17 $sth = $dbh->prepare("SELECT login, potype, exchange_id, imap_id, pop_id FROM users WHERE " .
18 "status = 1 OR status = 2 OR status = 5 OR status = 6") || exit $MR_DBMS_ERR;
19 $sth->execute || exit $MR_DBMS_ERR;
23 open(OUT, ">$outfile") || exit $MR_OCONFIG;
25 print OUT "; MIT Network Host Table\n;\n";
26 print OUT "; \t\$" . "Author:" . " \$\n";
27 print OUT "; \t\$" . "Date:" . " \$\n";
28 print OUT "; \t\$" . "Revision:" . " \$\n";
29 print OUT "; Host table generated by Moira at $tnow\n;\n";
31 while (($login, $potype, $exchange_id, $imap_id, $pop_id) = $sth->fetchrow_array) {
32 $login =~ tr/a-z/A-Z/;
34 if ($exchange_id != 0) {
35 $imap_filesystem = lc($login) . ".po";
36 ($mach_id) = $dbh->selectrow_array("SELECT mach_id FROM filesys " .
37 "WHERE label = " . $dbh->quote($imap_filesystem) .
39 if (defined($mach_id)) {
42 ($mach_id) = $dbh->selectrow_array("SELECT mach_id FROM machine WHERE " .
43 "name = 'IMAP.EXCHANGE.MIT.EDU'");
44 if (defined($mach_id)) {
51 ($mach_id) = $dbh->selectrow_array("SELECT mach_id FROM filesys WHERE " .
52 "filsys_id = " . $dbh->quote($imap_id) .
53 " AND type = 'IMAP'");
54 if (defined($mach_id)) {
59 ($hostname) = $dbh->selectrow_array("SELECT name FROM machine WHERE mach_id = " .
60 $dbh->quote($pop_id));
63 if ($pop_id != 0 && $potype ne "NONE") {
65 if (16 - length($login) > 8) {
71 $row = "$login$sp\tIN\tCNAME\t$hostname.\n";