]> andersk Git - moira.git/commitdiff
DCM for events calendar server, per request of tbelton.
authorzacheiss <zacheiss>
Mon, 11 Aug 2003 20:31:32 +0000 (20:31 +0000)
committerzacheiss <zacheiss>
Mon, 11 Aug 2003 20:31:32 +0000 (20:31 +0000)
gen/Makefile.in
gen/events.gen [new file with mode: 0755]

index dbdca593145e11255d3b0bfa4d1d038db4d57d58..e017f1dae1033656f51eaf2fa561d5a4acdb9b68 100644 (file)
@@ -42,10 +42,10 @@ 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 winad.gen www.gen zephyr.gen
 
-SCRIPTS=acl.sh aliases.sh boot.sh ca.gen calendar.gen dhcp.sh hesiod.sh \
-       ip-billing.gen ip-billing.sh longjobs.gen longjobs.sh mailhub.sh \
-       mailman.gen mailman.sh ndb.sh nfs.sh null.sh postoffice.sh print.sh \
-       sapprint.gen sapprint.sh spwatch.gen stellar.gen stellar.sh \
+SCRIPTS=acl.sh aliases.sh boot.sh ca.gen calendar.gen dhcp.sh events.gen \
+       hesiod.sh ip-billing.gen ip-billing.sh longjobs.gen longjobs.sh \
+       mailhub.sh mailman.gen mailman.sh ndb.sh nfs.sh null.sh postoffice.sh \
+       print.sh sapprint.gen sapprint.sh spwatch.gen stellar.gen stellar.sh \
        warehouse.sh www.sh zephyr.sh install_dirs install_quotas zero_quotas
 
 .SUFFIXES: .pc .gen
diff --git a/gen/events.gen b/gen/events.gen
new file mode 100755 (executable)
index 0000000..84b09fc
--- /dev/null
@@ -0,0 +1,55 @@
+#!/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/events.out';
+
+use DBI;
+
+$dbh = DBI->connect("dbi:Oracle:moira", "moira", "moira")
+  || exit $MR_DBMS_ERR;
+
+$sth = $dbh->prepare("SELECT name FROM list WHERE maillist = 1 AND active = 1")
+    || exit $MR_DBMS_ERR;
+
+$sth->execute || exit $MR_DBMS_ERR;
+
+umask 022;
+open(OUT, ">$outfile") || exit $MR_OCONFIG;
+
+while ($name = $sth->fetchrow_array) {
+    
+    $sth2 = $dbh->prepare("SELECT UNIQUE u.login FROM users u, imembers i, " .
+                         "list l WHERE l.name = " . $dbh->quote($name) .
+                         "AND l.list_id = i.list_id " .
+                         "AND i.member_type = 'USER' " .
+                         "AND i.member_id = u.users_id") || exit $MR_DBMS_ERR;
+
+    $sth2->execute || exit $MR_DBMS_ERR;
+                
+    $row = "$name:";
+    $row =~ s/\0//g;
+    print OUT $row;
+    $maybecomma = "";
+
+    while ($member = $sth2->fetchrow_array) {
+       $row = "$maybecomma$member";
+       $row =~ s/\0//g;
+       print OUT $row;
+       $maybecomma = ",";
+    }
+
+    $row = "\n";
+    $row =~ s/\0//g;
+    print OUT $row;
+}
+
+close(OUT);
+$dbh->disconnect;
+
+exit 0;
This page took 0.045236 seconds and 5 git commands to generate.