Last active
October 22, 2015 06:32
-
-
Save zivester/a61eb14fb25bcf067c69 to your computer and use it in GitHub Desktop.
download-ubuntu-torrents.pl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl | |
| # | |
| # Download all the torrents for a particular ubuntu release. | |
| # | |
| # Requires: wget | |
| # | |
| # Usage: | |
| # perl download-ubuntu-torrents.pl /tmp/ | |
| # | |
| use strict; | |
| my $SLEEP = 300; # seconds to wait until the next retry | |
| my $dest = $ARGV[0] || '.'; # destination directory to send torrents | |
| # it defaults to the current working directory | |
| my @versions = ( "15.10" ); # The version you want to download | |
| my @archs = ( "amd64", "i386" ); # The architecture | |
| my @types = ( "desktop", "server" ); # The release type | |
| for my $version (@versions){ | |
| for my $arch (@archs){ | |
| for my $type (@types){ | |
| my @cmd = ( | |
| "wget", | |
| "-P", | |
| $dest, | |
| "http://releases.ubuntu.com/$version/ubuntu-$version-$type-$arch.iso.torrent" | |
| ); | |
| print "@cmd\n"; | |
| my $error; | |
| do { | |
| $error = system(@cmd) | |
| and print "ERROR, going to retry in $SLEEP seconds\n"; | |
| } while ( $error && sleep $SLEEP ); | |
| } | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Too tired to finish, but a better rewrite in node.js use the official torrent.ubuntu.com:6699 mirror
TODO: Add polling/retries