From 1964ff671f4850ccbcbe7f464001b5f6802dba38 Mon Sep 17 00:00:00 2001 From: zacheiss Date: Fri, 18 Jan 2002 06:54:45 +0000 Subject: [PATCH] First cut of a DCM for stellar, and Makefile.in changes to install it. --- gen/Makefile.in | 4 +-- gen/stellar.gen | 84 +++++++++++++++++++++++++++++++++++++++++++++++++ gen/stellar.sh | 51 ++++++++++++++++++++++++++++++ 3 files changed, 137 insertions(+), 2 deletions(-) create mode 100755 gen/stellar.gen create mode 100644 gen/stellar.sh diff --git a/gen/Makefile.in b/gen/Makefile.in index 7331544c..1c8f0868 100644 --- a/gen/Makefile.in +++ b/gen/Makefile.in @@ -44,8 +44,8 @@ TARGET= acl.gen boot.gen dhcp.gen directory.gen hesiod.gen hosts.gen \ SCRIPTS=boot.sh ca.gen dhcp.sh hesiod.sh ip-billing.gen longjobs.gen \ longjobs.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 + 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/stellar.gen b/gen/stellar.gen new file mode 100755 index 00000000..45a16cfd --- /dev/null +++ b/gen/stellar.gen @@ -0,0 +1,84 @@ +#!/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; + +$ENV{PATH} = "/bin:/usr/bin:/sbin:/usr/sbin"; + +$outdir = '/moira/dcm/stellar'; +$outfile = '/moira/dcm/stellar.out'; +umask 022; + +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 = 'STELLAR' " . + "AND m.mach_id = sh.mach_id") || exit $MR_DBMS_ERR; +$sth0->execute; + +while (($root_list_id, $hostname) = $sth0->fetchrow_array) { + open(OUT, ">$outdir/$hostname"); + + $sth = $dbh->prepare("SELECT l.name 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 " . + "ORDER BY l.name") || exit $MR_DBMS_ERR; + $sth->execute; + + while (($name) = $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:"; + $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 = ","; + } + + $row = "\n"; + $row =~ s/\0//g; + print OUT $row; + } + close(OUT); +} + +system("cd $outdir && tar cf $outfile .") || exit $MR_OCONFIG; + +$dbh->disconnect; + +exit 0; diff --git a/gen/stellar.sh b/gen/stellar.sh new file mode 100644 index 00000000..0d5a33f9 --- /dev/null +++ b/gen/stellar.sh @@ -0,0 +1,51 @@ +#!/bin/sh +# +# $Header$ + +PATH=/usr/bin:/bin:/usr/sbin:/sbin + +if [ -d /var/athena ] && [ -w /var/athena ]; then + exec >/var/athena/moira_update.log 2>&1 +else + exec >/tmp/moira_update.log 2>&1 +fi + +# The following exit codes are defined and MUST BE CONSISTENT with the +# error codes the library uses: +MR_MISSINGFILE=47836473 +MR_MKCRED=47836474 +MR_TARERR=47836476 + +TARFILE=/var/tmp/stellar.out +SRCDIR=/var/tmp/stellar.dir + +uchost=`hostname | tr '[a-z]' '[A-Z]'` +echo $uchost | egrep -e "\." >/dev/null +if [ $? != 0 ]; then + uchost=$uchost.MIT.EDU +fi + +# Alert if the tar file does not exist +test -r $TARFILE || exit $MR_MISSINGFILE + +# Make a temporary directory to unpack the tar file into +rm -rf $SRCDIR +mkdir $SRCDIR || exit $MR_MKCRED +cd $SRCDIR || exit $MR_MKCRED + +# Extract everything +tar xpf $TARFILE || exit $MR_TARERR + +if [ -f "$uchost" ]; then + /var/local/stellar-support/moira-to-stellar.perl +else + exit $MR_MISSINGFILE +fi + +# cleanup +cd / +rm -rf $SRCDIR +test -f $TARFILE && rm -f $TARFILE +test -f $0 && rm -f $0 + +exit 0 -- 2.45.2