File:  [LON-CAPA] / loncom / production_dns_sanity.pl
Revision 1.3: download - view: text, annotated - select for diffs
Wed Aug 18 22:57:12 2010 UTC (13 years, 7 months ago) by www
Branches: MAIN
CVS tags: version_2_12_X, version_2_11_X, version_2_11_4_uiuc, version_2_11_4_msu, version_2_11_4, version_2_11_3_uiuc, version_2_11_3_msu, version_2_11_3, version_2_11_2_uiuc, version_2_11_2_msu, version_2_11_2_educog, version_2_11_2, version_2_11_1, version_2_11_0_RC3, version_2_11_0_RC2, version_2_11_0_RC1, version_2_11_0, version_2_10_X, version_2_10_1, version_2_10_0_RC2, version_2_10_0, loncapaMITrelate_1, language_hyphenation_merge, language_hyphenation, HEAD, BZ4492-merge, BZ4492-feature_horizontal_radioresponse, BZ4492-feature_Support_horizontal_radioresponse, BZ4492-Support_horizontal_radioresponse
* Clemson University
* Updated sanity-check to look for new host-table entries

use strict;
my %domserv=();
my %domname=();
my %hostdom=();
my %hostfunc=();

# Read the tables

open(IN,"production_dns_domain.tab");
while (my $line=<IN>) {
   if ($line=~/^\s*\#/) { next; }
   chomp($line);
   unless ($line=~/\S/) { next; }
   my ($domain,$name,$auth,$authparm,$lang,$city,$coord1,$coord2,$lib)=split(/\:/,$line);
   if ($domserv{$domain}) {
      print "Domain $domain defined more than once in domain.tab\n";
   }
   $domserv{$domain}=$lib;
   $domname{$domain}=$name;
}
close(IN);
open(IN,"production_dns_hosts.tab");
while (my $line=<IN>) {
   if ($line=~/^\s*\#/) { next; }
   chomp($line);
   unless ($line=~/\S/) { next; }
   my ($server,$domain,$function,$ip,$protocol,$interdom)=split(/\:/,$line);
   unless (($protocol eq 'http') || ($protocol eq 'https')) {
      print "Invalid protocol $protocol for $server\n";
   }
   unless ($interdom=~/\./) {
      print "Invalid internet domain $interdom for $server\n";
   }
   if ($hostdom{$server}) {
      print "$server defined more than once in hosts.tab\n";
   }
   $hostdom{$server}=$domain;
   $hostfunc{$server}=$function;
}
close(IN);

# Every mentioned library server should be in hosts.tab

my $doms=0;
foreach my $dom (keys %domserv) {
    unless ($hostdom{$domserv{$dom}} eq $dom) {
       print "Did not find $domserv{$dom} in hosts.tab\n";
    }
    unless ($hostfunc{$domserv{$dom}} eq 'library') {
       print "$domserv{$dom} is not a library server ($hostfunc{$domserv{$dom}})\n";
    }
    $doms++;
}

# Every server should have a valid domain

my $servs=0;
foreach my $serv (keys %hostdom) {
   unless ($domserv{$hostdom{$serv}}) {
      print "Server $serv has invalid domain in hosts.tab\n";
   }
   unless (($hostfunc{$serv} eq 'library') || ($hostfunc{$serv} eq 'access')) {
      print "Server $serv has invalid function $hostfunc{$serv} in hosts.tab\n";
   }
   $servs++;
}
print "\nValidated $doms domains and $servs servers\n";


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>