Add mirror scripts and config
authorAlexander Wirt <formorer@debian.org>
Wed, 4 Jan 2012 21:44:45 +0000 (22:44 +0100)
committerAlexander Wirt <formorer@debian.org>
Wed, 4 Jan 2012 21:44:45 +0000 (22:44 +0100)
bin/generate_mirror_map [new file with mode: 0755]
bin/masterlist2mirmon [moved from masterlist2mirmon with 100% similarity]
bin/run_mirmon [new file with mode: 0755]
etc/mirmon.conf [new file with mode: 0644]

diff --git a/bin/generate_mirror_map b/bin/generate_mirror_map
new file mode 100755 (executable)
index 0000000..224cbcd
--- /dev/null
@@ -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}}));
+}
similarity index 100%
rename from masterlist2mirmon
rename to bin/masterlist2mirmon
diff --git a/bin/run_mirmon b/bin/run_mirmon
new file mode 100755 (executable)
index 0000000..eb27e2c
--- /dev/null
@@ -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 (file)
index 0000000..bdea965
--- /dev/null
@@ -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