Lukas> Once someone posted this script to find the fastest debian mirror, Lukas> which could be used in some way in the postinst of apt:
IIRC Chris Lameter wrote this as part of one of his misc. utility packages. I rewrote it in perl (and added a thing or two) as part of the mirror package which installs it under the name 'debian-mirrors'. As it's short and sweet, I include it here: #!/usr/bin/perl # # debian-mirrors measure ping time to all mirrors in README.mirrors # # downloads README.mirrors from ftp.debian.org (but not if a local file is # pointed to), runs fping on all Debian mirrors, sorts the result by ping # time and output the 'n' (default is 20) fastest # # Written by Dirk Eddelbuettel <[EMAIL PROTECTED]> and released under the GPL # $Id: debian-mirrors.pl,v 1.3 1998/02/19 02:12:02 edd Exp $ ## Yes, Net::FTP is much cooler, but we don't want to depend on libnet-perl ## 'ftp.pl' is provided by the mirror package unshift( @INC, "/usr/lib/mirror" ); require 'ftp.pl'; #use strict; # doesn't work with ftp.pl use English; use File::Basename; use vars qw($opt_h $opt_f $opt_v); use Getopt::Std; use IPC::Open2; my $tempfile = "/tmp/".$file."-".$$; my $readfrom = $tempfile; my $max = 20; $PROGRAM_NAME =~ s|.*/||; # strip everything before last slash getopts('hf:n:v') or die("Try `$PROGRAM_NAME -h` for help screen.\n"); if ($opt_h or $#ARGV != -1) { print "Usage:\n $PROGRAM_NAME [options]\n"; print "Options:\n"; print " -f file\tpoint to local version README.mirrors\n"; print " -n max\tmaximum number of mirrors to show\n"; print " -v\t\tverbose operation\n"; print " -h\t\tshow this help\n"; exit 0; } $max = $opt_n if ($opt_n); print "Max is set to $max\n" if $opt_v; if ( ! $opt_f ) { my $hostname = "ftp.debian.org"; my $account = "ftp"; my $password = "[EMAIL PROTECTED]"; my $directory = "/pub/debian"; my $filename = "README.mirrors"; print "Retrieving ", $filename, " for analysis."; ftp::debug(1) if $opt_v; # for debugging output ftp::open($hostname,21,0,1) or die "No ftp connection\n"; ftp::login($account, $password) or die "Couldn't login\n"; ftp::cwd($directory) or die "Cannot cd to $directory\n"; ftp::get($filename, $tempfile, 0) or die "Could not get $file\n"; ftp::quit(); } else { die "File $opt_f does not exist." unless -f $opt_f; $readfrom = $opt_f; } print "Measuring ping times to all Debian mirror sites. " if $opt_v; print "Please be patient.\n" if $opt_v; my ($mirror,$path,$time); open(DATA, $readfrom) or die "Cannot open $filename\n"; open2("PINGOUT", "PINGIN", "fping -ae") or die "Cannot start fping(1)\n";; while (<DATA>) { if (($mirror,$path) = ($ARG =~ m|^\s*(\S*\.\S*\.\S*.*):(/\S*)\s.*|)) { print "Pinging $mirror \n" if $opt_v; print PINGIN "$mirror\n"; # if ($mirror =~ m/.*\.edu$/); } } close(DATA); close(PINGIN); open2("SORTOUT", "SORTIN", "sort -n") or die "Cannot start sort(1)\n"; while (<PINGOUT>) { ($mirror,$time) = ($ARG =~ m|^(\S*)\s*\((\d*) msec\)|); print "fping reports $time for $mirror\n" if $opt_v; print SORTIN "$time $mirror\n"; } close(SORTIN); close(PINGOUT); my $i=1; while (<SORTOUT>) { print "$_"; last if ($i++ == $max); } close(SORTOUT); -- Linux is not only free; it is, arguably, a better operating system, offering a degree of stability and an ability to scale up that NT cannot match. -- The Economist, Oct 3, 1998