X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=bin%2Fgenerate_mirror_map;fp=bin%2Fgenerate_mirror_map;h=a1c34ad4a191dd8f88841c911ab29cf4160eb40e;hb=bed63588fab781e0910fa3c97cac8a814c8188b0;hp=224cbcdea914a0c4e8b93d5c297c0cda3f147b2f;hpb=f514926d0e16fd45450d718b4d4f4e7e3ceb14cb;p=grml-mirrors.git diff --git a/bin/generate_mirror_map b/bin/generate_mirror_map index 224cbcd..a1c34ad 100755 --- a/bin/generate_mirror_map +++ b/bin/generate_mirror_map @@ -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}})); + } }