]> andersk Git - moira.git/commitdiff
Bring back the Central America DCM, and install it's .gen.
authorzacheiss <zacheiss>
Fri, 15 Sep 2000 05:09:36 +0000 (05:09 +0000)
committerzacheiss <zacheiss>
Fri, 15 Sep 2000 05:09:36 +0000 (05:09 +0000)
gen/Makefile.in
gen/ca.gen [new file with mode: 0755]

index 45ae45d78517439acb9e0acf41c5aababd86c852..f5dde8c3911ffc09c8cafd90b60561518ebe97b2 100644 (file)
@@ -42,7 +42,7 @@ TARGET=       acl.gen boot.gen dhcp.gen directory.gen hesiod.gen hosts.gen \
        mailhub.gen ndb.gen network.gen nfs.gen pobox.gen \
        postoffice.gen print.gen warehouse.gen www.gen zephyr.gen
 
-SCRIPTS=boot.sh dhcp.sh hesiod.sh mailhub.sh ndb.sh nfs.sh null.sh \
+SCRIPTS=boot.sh ca.gen dhcp.sh hesiod.sh mailhub.sh ndb.sh nfs.sh null.sh \
        postoffice.sh print.sh sapprint.gen sapprint.sh spwatch.gen \
        warehouse.sh www.sh zephyr.sh install_dirs install_quotas \
        zero_quotas
diff --git a/gen/ca.gen b/gen/ca.gen
new file mode 100755 (executable)
index 0000000..c3a489b
--- /dev/null
@@ -0,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;
This page took 0.075809 seconds and 5 git commands to generate.