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 ($mach_id) = $dbh->selectrow_array("SELECT mach_id FROM machine WHERE " .
36 "name = 'IMAP.EXCHANGE.MIT.EDU'");
37 if (defined($mach_id)) {
43 ($mach_id) = $dbh->selectrow_array("SELECT mach_id FROM filesys WHERE " .
44 "filsys_id = " . $dbh->quote($imap_id) .
45 " AND type = 'IMAP'");
46 if (defined($mach_id)) {
51 ($hostname) = $dbh->selectrow_array("SELECT name FROM machine WHERE mach_id = " .
52 $dbh->quote($pop_id));
55 if ($pop_id != 0 && $potype ne "NONE") {
57 if (16 - length($login) > 8) {
63 $row = "$login$sp\tIN\tCNAME\t$hostname.\n";