[1669] in Moira
central america DCM
daemon@ATHENA.MIT.EDU (Garry Zacheiss)
Fri Sep 15 01:05:52 2000
Message-Id: <200009150505.BAA10507@hodge-podge.mit.edu>
To: moiradev@MIT.EDU
Date: Fri, 15 Sep 2000 01:05:49 -0400
From: Garry Zacheiss <zacheiss@MIT.EDU>
Back, by popular demand.
Index: ca.gen
===================================================================
RCS file: ca.gen
diff -N ca.gen
*** /dev/null Thu Sep 14 23:20:07 2000
--- ca.gen Fri Sep 15 01:04:34 2000
***************
*** 0 ****
--- 1,66 ----
+ #!/moira/bin/perl -Tw
+
+ # $Id$
+
+ # The following exit codes are defined and MUST BE CONSISTENT with the
+ # error codes the library uses:
+ $MR_DBMS_ERR = 47836421;
+ $MR_OCONFIG = 47836460;
+
+ $outfile = '/moira/dcm/ca.out';
+
+ use DBI;
+ $dbh = DBI->connect("dbi:Oracle:moira", "moira", "moira")
+ || exit $MR_DBMS_ERR;
+
+ # First, let's do people with NFS homedirs, since it's not hard.
+ $sth = $dbh->prepare("SELECT n.nfsphys_id, n.dir, m.name ".
+ "FROM nfsphys n, machine m ".
+ "WHERE m.mach_id = n.mach_id ".
+ "ORDER BY n.nfsphys_id") || exit $MR_DBMS_ERR;
+
+ $sth->execute || exit $MR_DBMS_ERR;
+
+ umask 022;
+ open(OUT, ">$outfile") || exit $MR_OCONFIG;
+
+ while (($id, $dir, $machname) = $sth->fetchrow_array) {
+ next if ($id == 0);
+ $foo = $dbh->prepare("SELECT u.login, u.fullname ".
+ "FROM users u, filesys f ".
+ "WHERE f.label = u.login AND u.status = 1 ".
+ "AND f.phys_id = " . $dbh->quote($id));
+ $first = 1;
+ $foo->execute || exit $MR_DBMS_ERR;
+ while (($login, $fullname) = $foo->fetchrow_array) {
+ if ($first) {
+ $first = 0;
+ print OUT "*$machname:$dir\n";
+ }
+ print OUT "$login,$fullname\n";
+ }
+ }
+
+ #Now, let's do all the AFS homedirs. This will take a while longer.
+ $sth = $dbh->prepare("SELECT UNIQUE u.login, u.fullname, f.name ".
+ "FROM users u, filesys f ".
+ "WHERE f.label = u.login AND u.status = 1 ".
+ "AND f.type = 'AFS' ".
+ "ORDER BY u.login") || exit $MR_DBMS_ERR;
+
+ $sth->execute || exit $MR_DBMS_ERR;
+
+ while (($login, $name, $dir) = $sth->fetchrow_array) {
+ $dir =~ /(\/.*)\//;
+ $path = $1;
+ if ($path ne $last) {
+ $last = $path;
+ print OUT "*AFS:$path\n";
+ }
+ print OUT "$login,$name\n";
+ }
+
+ close(OUT);
+ $dbh->disconnect;
+
+ exit 0;