File:  [LON-CAPA] / loncom / development_dns_sanity.pl
Revision 1.1: download - view: text, annotated - select for diffs
Thu Jun 9 19:36:06 2011 UTC (12 years, 9 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, loncapaMITrelate_1, language_hyphenation_merge, language_hyphenation, HEAD, BZ4492-merge, BZ4492-feature_horizontal_radioresponse, BZ4492-feature_Support_horizontal_radioresponse, BZ4492-Support_horizontal_radioresponse
Development DNS Sanity and fixing MIT entry

    1: use strict;
    2: my %domserv=();
    3: my %domname=();
    4: my %hostdom=();
    5: my %hostfunc=();
    6: 
    7: # Read the tables
    8: 
    9: open(IN,"development_dns_domain.tab");
   10: while (my $line=<IN>) {
   11:    if ($line=~/^\s*\#/) { next; }
   12:    chomp($line);
   13:    unless ($line=~/\S/) { next; }
   14:    my ($domain,$name,$auth,$authparm,$lang,$city,$coord1,$coord2,$lib)=split(/\:/,$line);
   15:    if ($domserv{$domain}) {
   16:       print "Domain $domain defined more than once in domain.tab\n";
   17:    }
   18:    $domserv{$domain}=$lib;
   19:    $domname{$domain}=$name;
   20: }
   21: close(IN);
   22: open(IN,"development_dns_hosts.tab");
   23: while (my $line=<IN>) {
   24:    if ($line=~/^\s*\#/) { next; }
   25:    chomp($line);
   26:    unless ($line=~/\S/) { next; }
   27:    my ($server,$domain,$function,$ip,$protocol,$interdom)=split(/\:/,$line);
   28:    unless (($protocol eq 'http') || ($protocol eq 'https')) {
   29:       print "Invalid protocol $protocol for $server\n";
   30:    }
   31:    unless ($interdom=~/\./) {
   32:       print "Invalid internet domain $interdom for $server\n";
   33:    }
   34:    if ($hostdom{$server}) {
   35:       print "$server defined more than once in hosts.tab\n";
   36:    }
   37:    $hostdom{$server}=$domain;
   38:    $hostfunc{$server}=$function;
   39: }
   40: close(IN);
   41: 
   42: # Every mentioned library server should be in hosts.tab
   43: 
   44: my $doms=0;
   45: foreach my $dom (keys %domserv) {
   46:     unless ($hostdom{$domserv{$dom}} eq $dom) {
   47:        print "Did not find $domserv{$dom} in hosts.tab\n";
   48:     }
   49:     unless ($hostfunc{$domserv{$dom}} eq 'library') {
   50:        print "$domserv{$dom} is not a library server ($hostfunc{$domserv{$dom}})\n";
   51:     }
   52:     $doms++;
   53: }
   54: 
   55: # Every server should have a valid domain
   56: 
   57: my $servs=0;
   58: foreach my $serv (keys %hostdom) {
   59:    unless ($domserv{$hostdom{$serv}}) {
   60:       print "Server $serv has invalid domain in hosts.tab\n";
   61:    }
   62:    unless (($hostfunc{$serv} eq 'library') || ($hostfunc{$serv} eq 'access')) {
   63:       print "Server $serv has invalid function $hostfunc{$serv} in hosts.tab\n";
   64:    }
   65:    $servs++;
   66: }
   67: print "\nValidated $doms domains and $servs servers\n";
   68: 

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