From: Alexander Wirt Date: Wed, 4 Jan 2012 21:44:45 +0000 (+0100) Subject: Add mirror scripts and config X-Git-Url: http://git.grml.org/?p=grml-mirrors.git;a=commitdiff_plain;h=a250637fc6e6e7b5f1436c7992e84bc93226e5a6 Add mirror scripts and config --- 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}})); +} diff --git a/masterlist2mirmon b/bin/masterlist2mirmon similarity index 100% rename from masterlist2mirmon rename to bin/masterlist2mirmon diff --git a/bin/run_mirmon b/bin/run_mirmon new file mode 100755 index 0000000..eb27e2c --- /dev/null +++ b/bin/run_mirmon @@ -0,0 +1,13 @@ +#!/bin/sh + +#update mirrorlist from git +cd /usr/local/src/grml-mirrors +git reset --hard >/dev/null +git pull >/dev/null +perl masterlist2mirmon Mirrors.masterlist > /etc/mirmon/mirror.list +#first run mirmon +LC_ALL=C /usr/bin/mirmon -q -get update 2>/dev/null +#then generatore the mirror map +/usr/local/bin/generate_mirror_map > /etc/apache2/grml.map +#give a hint to apache2 +/usr/sbin/apache2ctl graceful diff --git a/etc/mirmon.conf b/etc/mirmon.conf new file mode 100644 index 0000000..bdea965 --- /dev/null +++ b/etc/mirmon.conf @@ -0,0 +1,23 @@ +# for detail, see its manual page. + +countries /usr/share/mirmon/countries.list +timeout 10 + + +# example for Debian mirror +project_name GRML +project_url http://www.grml.org/ +project_logo http://grml.org/img/logo.png +mirror_list /etc/mirmon/mirror.list +probe /usr/bin/probe -q -t %TIMEOUT% %URL%timestamp.txt +min_sync 6h +max_sync 12h +min_poll 30m +max_poll 1h +# /usr/bin/wget -q -O - -T %TIMEOUT% -t 1 %URL%timestamp.txt + +state /var/lib/mirmon/state +web_page /var/www/mirror.grml.org/index.html + +# about icons' location, see sample apache configuration +icons icons