Annotation of loncom/production_dns_sanity.pl, revision 1.2

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,"production_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);
1.2     ! www        15:    if ($domserv{$domain}) {
        !            16:       print "Domain $domain defined more than once in domain.tab\n";
        !            17:    }
1.1       www        18:    $domserv{$domain}=$lib;
                     19:    $domname{$domain}=$name;
                     20: }
                     21: close(IN);
                     22: open(IN,"production_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)=split(/\:/,$line);
                     28:    if ($hostdom{$server}) {
                     29:       print "$server defined more than once in hosts.tab\n";
                     30:    }
                     31:    $hostdom{$server}=$domain;
                     32:    $hostfunc{$server}=$function;
                     33: }
                     34: close(IN);
                     35: 
                     36: # Every mentioned library server should be in hosts.tab
                     37: 
                     38: foreach my $dom (keys %domserv) {
                     39:     unless ($hostdom{$domserv{$dom}} eq $dom) {
                     40:        print "Did not find $domserv{$dom} in hosts.tab\n";
                     41:     }
                     42:     unless ($hostfunc{$domserv{$dom}} eq 'library') {
                     43:        print "$domserv{$dom} is not a library server ($hostfunc{$domserv{$dom}})\n";
                     44:     }
                     45: }
1.2     ! www        46: 
        !            47: # Every server should have a valid domain
        !            48: 
        !            49: foreach my $serv (keys %hostdom) {
        !            50:    unless ($domserv{$hostdom{$serv}}) {
        !            51:       print "Server $serv has invalid domain in hosts.tab\n";
        !            52:    }
        !            53:    unless (($hostfunc{$serv} eq 'library') || ($hostfunc{$serv} eq 'access')) {
        !            54:       print "Server $serv has invalid function $hostfunc{$serv} in hosts.tab\n";
        !            55:    }
        !            56: }

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