X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=bin%2Fgenerate_mirror_map;fp=bin%2Fgenerate_mirror_map;h=224cbcdea914a0c4e8b93d5c297c0cda3f147b2f;hb=a250637fc6e6e7b5f1436c7992e84bc93226e5a6;hp=0000000000000000000000000000000000000000;hpb=fe0f488872eaf4c3de11dd889cfab960079bf392;p=grml-mirrors.git diff --git a/bin/generate_mirror_map b/bin/generate_mirror_map new file mode 100755 index 0000000..224cbcd --- /dev/null +++ b/bin/generate_mirror_map @@ -0,0 +1,28 @@ +#!/usr/bin/perl + +use lib '/usr/share/perl5/'; + +use Mirmon::Mirmon ; + +$m = Mirmon -> new ( '/etc/mirmon.conf' ); + +$conf = $m->conf ; # a Mirmon::Conf object +$state = $m->state ; # the mirmon state + +use Data::Dumper; +my $mirrors; +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; + $mirrors->{ $region } ||= []; + $url =~ s/^http:\/\///; + push @{$mirrors->{ $region }}, $url; +} + +foreach my $region (keys %{$mirrors}) { + printf ("%s %s\n", lc($region), join('|', @{$mirrors->{$region}})); +}