Annotation of loncom/development_dns_sanity.pl, revision 1.1

1.1     ! www         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>