summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--conf/rsync/g.mirrors.extra3
-rwxr-xr-xprobe-mirmon42
2 files changed, 35 insertions, 10 deletions
diff --git a/conf/rsync/g.mirrors.extra b/conf/rsync/g.mirrors.extra
index b77eb9e..63e5116 100644
--- a/conf/rsync/g.mirrors.extra
+++ b/conf/rsync/g.mirrors.extra
@@ -1,6 +1,5 @@
gentoo rsync://masterportage.gentoo.org/
gentoo rsync://albatross.gentoo.org/
-gentoo rsync://boobie.gentoo.org/
gentoo rsync://dipper.gentoo.org/
gentoo rsync://starling.gentoo.org/
-gentoo rsync://swan.gentoo.org/
+gentoo rsync://turnstone.gentoo.org/
diff --git a/probe-mirmon b/probe-mirmon
index ff73776..cfade50 100755
--- a/probe-mirmon
+++ b/probe-mirmon
@@ -29,6 +29,11 @@ sub main {
if ( $url =~ m,^rsync://, ) {
handle_rsync( $timeout, $url );
}
+ elsif ( $url =~ m,^ftp://, ) {
+ # Hacky, at some point CURL stopped returning the output here; just go back to wget for now.
+ #handle_libcurl( $timeout, $url );
+ handle_wget( $timeout, $url );
+ }
else {
handle_libcurl( $timeout, $url );
}
@@ -44,6 +49,7 @@ sub handle_libcurl {
$curl->setopt(CURLOPT_TIMEOUT, $timeout);
$curl->setopt(CURLOPT_FTP_USE_EPSV, 1);
$curl->setopt(CURLOPT_URL, $url);
+ $curl->setopt(CURLOPT_VERBOSE, 1) if $url =~ m,^ftp://,;
# A filehandle, reference to a scalar or reference to a typeglob can be used here.
my $response_body;
@@ -70,7 +76,15 @@ sub handle_wget {
my ( $timeout, $url ) = @_;
# TODO: replace this with native HTTP
# TODO: munge the output!
- exec {'/usr/bin/wget'} 'wget', qw( -q --passive-ftp -O - -T ), $timeout, '-t', 1, $url;
+ # kill -9 wget when it gets really stuck.
+ my $tmpdir = File::Tempdir->new();
+ my $dir = $tmpdir->name;
+ my $file = $url;
+
+ $file =~ s/\W/_/g; # translate all non-letters to _
+ system {'/usr/bin/timeout'} qw(--preserve-status -s KILL -k ), ($timeout + 1), ($timeout + 0.5),
+ 'wget', qw( -q --passive-ftp -T ), $timeout, '-t', 1, '-O', "$dir/$file", $url;
+ slurp_and_output("$dir/$file");
}
sub handle_rsync {
@@ -84,20 +98,18 @@ sub handle_rsync {
# https://stackoverflow.com/a/6331618/1583179
my ($stdout, $stderr, $ret) = capture {
- system '/usr/bin/rsync', qw( -q --no-motd --timeout ), $timeout, $url, "$dir/$file";
+ system {'/usr/bin/rsync'} qw( -q --no-motd --timeout ), $timeout, $url, "$dir/$file";
};
+ #print "STDOUT: $stdout\n";
+ #print "STDERR $stderr\n";
+ #print "RET: $ret\n";
if ($ret!=0) {
#warn "rsync failed, exit code $fail, $! $? $@\n";
#exit $ret;
exit 800;
}
- open my $fh, '<', "$dir/$file" or do {
- warn "Opening Downloaded timestamp Failed";
- exit 900; # rediculous exit code.
- };
-
- print munge_date(<$fh>);
+ slurp_and_output("$dir/$file");
exit 0;
}
@@ -105,6 +117,7 @@ sub handle_rsync {
sub munge_date {
no warnings 'numeric'; ## no critic (TestingAndDebugging::ProhibitNoWarnings)
my $timestr = shift;
+ return -1 if !$timestr;
my $timestamp = int($timestr);
my $year2020 = 1577836800;
my $year2038 = 2145916800;
@@ -117,3 +130,16 @@ sub munge_date {
}
return -1;
}
+
+sub slurp_and_output {
+ my $filename = shift;
+ open my $fh, '<', $filename or do {
+ warn "Opening Downloaded timestamp Failed";
+ exit 900; # rediculous exit code.
+ };
+ my $line = <$fh>;
+ #print "RAW: $line\n";
+
+ print munge_date($line), "\n";
+ exit 0;
+}