292 1.44 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
#
# Compare tipservers table vs. all servers listed in tiplines and warn
# if there is a discrepancy.
#
# With the latest version of capserver, only nodes listed in tipservers
# are allowed to report info.
#
use strict;
use libdb;

my $impotent = 0;

sub DoUpdate($$$)
{
    my ($dbhandle, $dbname, $version) = @_;
    my %servers = ();

    my $query_result =
	DBQueryFatal("select server from tipservers");
    while (my $row = $query_result->fetchrow_hashref()) {
	my $server = $row->{'server'};
	if (!defined($server) || $server eq "") {
	    print STDERR "*** WARNING: NULL tipservers entry ignored\n";
	    next;
	}
	$servers{$server} = 0;
    }

    $query_result =
	DBQueryFatal("select server from tiplines group by server");
    while (my $row = $query_result->fetchrow_hashref()) {
	my $server = $row->{'server'};
	if (!defined($server) || $server eq "") {
	    print STDERR "*** WARNING: NULL server in tiplines entries!\n";
	    next;
	}
	if (!exists($servers{$server})) {
	    print STDERR "Tip server '$server' has 'tiplines' entries ".
		"but no 'tipservers' entry\n";
	    print STDERR " Adding entry...\n";
	    DBQueryFatal("INSERT INTO tipservers VALUES ('$server')");
	} else {
	    $servers{$server} = 1;
	}
    }

    foreach my $server (keys %servers) {
	if ($servers{$server} == 0) {
	    print STDERR "*** WARNING: no 'tiplines' entries associated with ".
		"server '$server'; consider removing from 'tipservers'\n";
	}
    }

    return 0;
}

1;