From 328f0c3db5770ce36a1f7f1b7c95af26d9683927 Mon Sep 17 00:00:00 2001 From: zacheiss Date: Thu, 2 Aug 2001 17:21:10 +0000 Subject: [PATCH] Add longjobs DCM and install it. --- gen/Makefile.in | 8 +++---- gen/longjobs.gen | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 4 deletions(-) create mode 100755 gen/longjobs.gen diff --git a/gen/Makefile.in b/gen/Makefile.in index e20a2b1a..9e076a0d 100644 --- a/gen/Makefile.in +++ b/gen/Makefile.in @@ -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=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 +SCRIPTS=boot.sh ca.gen dhcp.sh hesiod.sh longjobs.gen 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 .SUFFIXES: .pc .gen diff --git a/gen/longjobs.gen b/gen/longjobs.gen new file mode 100755 index 00000000..1645274f --- /dev/null +++ b/gen/longjobs.gen @@ -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/longjobs.out'; + +use DBI; + +$dbh = DBI->connect("dbi:Oracle:moira", "moira", "moira") + || exit $MR_DBMS_ERR; + +$sth = $dbh->prepare("SELECT name FROM list WHERE grouplist = 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; -- 2.45.2