Annotation of loncom/production_dns_sanity.pl, revision 1.3
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; }
1.3 ! www 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: }
1.1 www 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:
1.3 ! www 44: my $doms=0;
1.1 www 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: }
1.3 ! www 52: $doms++;
1.1 www 53: }
1.2 www 54:
55: # Every server should have a valid domain
56:
1.3 ! www 57: my $servs=0;
1.2 www 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: }
1.3 ! www 65: $servs++;
1.2 www 66: }
1.3 ! www 67: print "\nValidated $doms domains and $servs servers\n";
! 68:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>