]> andersk Git - moira.git/commitdiff
Changes requested by csnowden.
authorzacheiss <zacheiss>
Wed, 8 Aug 2007 00:49:22 +0000 (00:49 +0000)
committerzacheiss <zacheiss>
Wed, 8 Aug 2007 00:49:22 +0000 (00:49 +0000)
gen/confluence.gen

index 4513b5eb1a5af7391cd2ebee534e893b95f5ba47..1ebe126baf87b8391174525f3870e9d411aab766 100755 (executable)
@@ -8,7 +8,7 @@ $MR_DBMS_ERR = 47836421;
 
 $ENV{PATH} = "/bin:/usr/bin:/sbin:/usr/sbin";
 
-$outdir = '/moira/dcm/confluence';
+$outfile = '/moira/dcm/confluence.out';
 umask 022;
 
 use DBI;
@@ -16,65 +16,56 @@ use DBI;
 $dbh = DBI->connect("dbi:Oracle:moira", "moira", "moira")
   || exit $MR_DBMS_ERR;
 
-$sth0 = $dbh->prepare("SELECT l.list_id, m.name " .
-                     "FROM list l, machine m, serverhosts sh " .
-                     "WHERE sh.value3 = l.name AND sh.service = 'CONFLUENCE' " .
-                     "AND m.mach_id = sh.mach_id") || exit $MR_DBMS_ERR;
-$sth0->execute;
+open(OUT, ">$outfile");
 
-while (($root_list_id, $hostname) = $sth0->fetchrow_array) {
-    open(OUT, ">$outdir/$hostname");
+$sth = $dbh->prepare("SELECT l.name, l.gid FROM list l " .
+                    "WHERE l.name LIKE 'confluence-%' AND l.active = 1 " .
+                    "AND l.grouplist = 1 ORDER by l.name") || exit $MR_DBMS_ERR;
 
-    $sth = $dbh->prepare("SELECT l.name, l.gid FROM list l, imembers i " .
-                        "WHERE i.list_id = " . $dbh->quote($root_list_id) .
-                        "AND i.member_type = 'LIST' " .
-                        "AND i.member_id = l.list_id AND i.direct = 1 " .
-                        "AND l.grouplist = 1 ORDER BY l.name") || exit $MR_DBMS_ERR;
-    $sth->execute;
+$sth->execute;
     
-    while (($name, $gid) = $sth->fetchrow_array) {
-       $sth2 = $dbh->prepare("SELECT UNIQUE i.member_type, i.member_id " .
-                             "FROM imembers i, list l " .
-                             "WHERE l.name = " . $dbh->quote($name) .
-                             "AND i.list_id = l.list_id " .
-                             "AND (i.member_type = 'USER' " .
-                             "OR i.member_type = 'STRING')") || 
-                                 exit $MR_DBMS_ERR;
-       $sth2->execute;
-       
-       $row = "$name:$gid:";
-       $row =~ s/\0//g;
-       print OUT $row;
-       $maybecomma = "";
-       
-       while (($type, $id) = $sth2->fetchrow_array) {
-           if ($type eq "USER") {
-               ($member) = $dbh->selectrow_array("SELECT login FROM users " .
-                                                 "WHERE users_id = " . 
-                                                 $dbh->quote($id)) ||
-                                                     exit $MR_DBMS_ERR;
-               $member = $member . "\@mit.edu";
-           }
-           elsif ($type eq "STRING") {
-               ($member) = $dbh->selectrow_array("SELECT string " .
-                                                 "FROM strings " .
-                                                 "WHERE string_id = " .
-                                                 $dbh->quote($id)) ||
-                                                     exit $MR_DBMS_ERR;
-           }
-           $row = "$maybecomma$member";
-           $row =~ s/\0//g;
-           print OUT $row;
-           $maybecomma = ",";
+while (($name, $gid) = $sth->fetchrow_array) {
+    $sth2 = $dbh->prepare("SELECT UNIQUE i.member_type, i.member_id " .
+                         "FROM imembers i, list l " .
+                         "WHERE l.name = " . $dbh->quote($name) .
+                         "AND i.list_id = l.list_id " .
+                         "AND (i.member_type = 'USER' " .
+                         "OR i.member_type = 'STRING')") || 
+                         exit $MR_DBMS_ERR;
+    $sth2->execute;
+    
+    $row = "$name:$gid:";
+    $row =~ s/\0//g;
+    print OUT $row;
+    $maybecomma = "";
+    
+    while (($type, $id) = $sth2->fetchrow_array) {
+       if ($type eq "USER") {
+           ($member) = $dbh->selectrow_array("SELECT login FROM users " .
+                                             "WHERE users_id = " . 
+                                             $dbh->quote($id)) ||
+                                             exit $MR_DBMS_ERR;
+           $member = $member . "\@mit.edu";
+       }
+       elsif ($type eq "STRING") {
+           ($member) = $dbh->selectrow_array("SELECT string " .
+                                             "FROM strings " .
+                                             "WHERE string_id = " .
+                                             $dbh->quote($id)) ||
+                                             exit $MR_DBMS_ERR;
        }
-       
-       $row = "\n";
+       $row = "$maybecomma$member";
        $row =~ s/\0//g;
        print OUT $row;
+       $maybecomma = ",";
     }
-    close(OUT);
+    
+    $row = "\n";
+    $row =~ s/\0//g;
+    print OUT $row;
 }
 
+close(OUT);
 $dbh->disconnect;
 
 exit 0;
This page took 0.138797 seconds and 5 git commands to generate.