X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=bin%2Fgenerate_mirror_map;h=6d37e1b19cf907c58bd1043d077d3339469b2464;hb=6c08fabf751bc78c526d7bf7e7c48c8d34800268;hp=224cbcdea914a0c4e8b93d5c297c0cda3f147b2f;hpb=a250637fc6e6e7b5f1436c7992e84bc93226e5a6;p=grml-mirrors.git diff --git a/bin/generate_mirror_map b/bin/generate_mirror_map index 224cbcd..6d37e1b 100755 --- a/bin/generate_mirror_map +++ b/bin/generate_mirror_map @@ -2,7 +2,7 @@ use lib '/usr/share/perl5/'; -use Mirmon::Mirmon ; +use Mirmon ; $m = Mirmon -> new ( '/etc/mirmon.conf' ); @@ -11,18 +11,26 @@ $state = $m->state ; # the mirmon state use Data::Dumper; my $mirrors; +my $regions_hash; foreach my $url ( keys %{$state} ) { next unless $url =~ /^http/; $mirror = $state -> { $url } ; # a Mirmon::Mirror object my ($time, $history) = split('-', $mirror->{state_history}); my $last_state = substr($history,-1,1); - next if $last_state eq 'f'; my $region = $mirror->region; + $regions_hash->{$region} = 1; + next if $last_state eq 'f'; $mirrors->{ $region } ||= []; $url =~ s/^http:\/\///; push @{$mirrors->{ $region }}, $url; } -foreach my $region (keys %{$mirrors}) { - printf ("%s %s\n", lc($region), join('|', @{$mirrors->{$region}})); +my @regions = keys(%$regions_hash); + +foreach my $region (@regions) { + if (scalar(@{$mirrors->{$region}}) == 0) { + printf ("%s %s\n", lc($region), join('|', @{$mirrors->{'DE'}})); + } else { + printf ("%s %s\n", lc($region), join('|', @{$mirrors->{$region}})); + } }