]> andersk Git - moira.git/blobdiff - gen/mailhosts.gen
EXCHANGE changes.
[moira.git] / gen / mailhosts.gen
index 310021131db9982047667e0ddea957f1ac9fcee8..892127e69b7e487aeee08bee9e1518eac1e1ced7 100755 (executable)
@@ -14,14 +14,8 @@ use DBI;
 $dbh = DBI->connect("dbi:Oracle:moira", "moira", "moira")
     || exit $MR_DBMS_ERR;
 
-$sth = $dbh->prepare("SELECT f.label, m.name ".
-                    "FROM filesys f, machine m, nfsphys p, serverhosts s ".
-                    "WHERE s.service='POSTOFFICE' AND s.mach_id=f.mach_id ".
-                    "AND f.mach_id=m.mach_id AND f.type='IMAP' ".
-                    "AND f.createflg!=0 AND f.mach_id=p.mach_id ".
-                    "AND f.phys_id=p.nfsphys_id ".
-                    "ORDER BY f.label")
-    || exit $MR_DBMS_ERR;
+$sth = $dbh->prepare("SELECT login, potype, exchange_id, imap_id, pop_id FROM users WHERE " .
+                    "status = 1 OR status = 2 OR status = 5 OR status = 6") || exit $MR_DBMS_ERR;
 $sth->execute || exit $MR_DBMS_ERR;
 
 $tnow = localtime;
@@ -34,21 +28,43 @@ print OUT "; \t\$" . "Date:" . " \$\n";
 print OUT "; \t\$" . "Revision:" . " \$\n";
 print OUT "; Host table generated by Moira at $tnow\n;\n";
 
-while (($label, $name) = $sth->fetchrow_array) {
-    $label =~ s/\.po$//;
-    $label =~ tr/a-z/A-Z/;
-    $name =~ tr/a-z/A-Z/;
+while (($login, $potype, $exchange_id, $imap_id, $pop_id) = $sth->fetchrow_array) {
+    $login =~ tr/a-z/A-Z/;
+
+    if ($exchange_id != 0) {
+       ($mach_id) = $dbh->selectrow_array("SELECT mach_id FROM machine WHERE " .
+                                          "name = 'IMAP.EXCHANGE.MIT.EDU'");
+       if (defined($mach_id)) {
+           $pop_id = $mach_id;
+       }
+    }
+
+    if ($imap_id != 0) {
+       ($mach_id) = $dbh->selectrow_array("SELECT mach_id FROM filesys WHERE " .
+                                          "filsys_id = " . $dbh->quote($imap_id) .
+                                          " AND type = 'IMAP'");
+       if (defined($mach_id)) {
+           $pop_id = $mach_id;
+       }
+    }
 
-    if (16 - length($label) > 8) {
+    ($hostname) = $dbh->selectrow_array("SELECT name FROM machine WHERE mach_id = " .
+                                       $dbh->quote($pop_id));
+
+
+    if ($pop_id != 0 && $potype ne "NONE") {
+
+       if (16 - length($login) > 8) {
        $sp = "\t";
     }
     else {
        $sp = "";
     }
-    $row = "$label$sp\tIN\tCNAME\t$name.\n";
+    $row = "$login$sp\tIN\tCNAME\t$hostname.\n";
     $row =~ s/\0//g;;
     print OUT $row;
 }
+}
 
 close(OUT);
 $dbh->disconnect;
This page took 0.212046 seconds and 4 git commands to generate.