File: download

package info (click to toggle)
golang-github-abh-geoip-dev 0.0~git20150611-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 112 kB
  • ctags: 79
  • sloc: perl: 25; makefile: 16
file content (29 lines) | stat: -rwxr-xr-x 922 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env perl
use strict;
use v5.12.0;
use LWP::Simple qw(mirror);
use File::Basename qw(basename);

my @files = qw(
  http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
  http://geolite.maxmind.com/download/geoip/database/GeoIPv6.dat.gz
  http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
  http://geolite.maxmind.com/download/geoip/database/GeoLiteCityv6-beta/GeoLiteCityv6.dat.gz
  http://download.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz
  http://download.maxmind.com/download/geoip/database/asnum/GeoIPASNumv6.dat.gz
);

for my $url (@files) {
    my $file       = basename($url);
    my ($dat_name) = ($file =~ m/(.*)\.gz/);
    my $rv         = mirror($url, $file);
    if ($rv == 200) {
        system("gzip -cd $file > $dat_name");
    }
    elsif ($rv == 304) {
        # already updated
    }
    else {
        say "$url:", $rv;
    }
}