/[pkgs]/devel/GeoIP/fetch-geoipdata-city.pl
ViewVC logotype

Contents of /devel/GeoIP/fetch-geoipdata-city.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download) (as text)
Fri Nov 28 23:55:43 2008 UTC (11 months, 3 weeks ago) by mfleming
Branch: MAIN
CVS Tags: GeoIP-1_4_5-2_fc11, F-12-split, GeoIP-1_4_6-1_fc11, GeoIP-1_4_6-2_fc12, F-11-split, GeoIP-1_4_5-3_fc11, GeoIP-1_4_5-1_fc11, GeoIP-1_4_7-0_1_20090931cvs_fc12, HEAD
Changes since 1.1: +1 -1 lines
File MIME type: text/x-perl
* Sat Nov 29 2008 Michael Fleming <mfleming+rpm@enlartenment.com> 1.4.5-1
- Update to 1.4.5
- Fix database URL locations in Perl helper scripts
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use POSIX;
6 use LWP::Simple;
7 use File::Copy;
8 use Carp;
9
10 my $ipdb = "GeoLiteCity.dat";
11 my $datadir = "/usr/share/GeoIP/";
12 my $fullpath = $datadir . $ipdb;
13 my $url = "http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz";
14 my $date = strftime "%Y%m%d", localtime;
15
16 # Do we have an existing IP database?
17 if ( -e $fullpath ) {
18 print "Fetching " . $ipdb . " from " . $url . "\r\n";
19 if ( is_success( getstore( $url, $datadir . "GeoLiteCity.dat.gz" ) ) ) {
20 move( $fullpath, $datadir . $ipdb . "." . $date )
21 || croak "Can't move the old database aside\r\n";
22 system( 'gzip', '-d', $datadir . 'GeoLiteCity.dat.gz' );
23 if ( $? ne 0 ) {
24 croak "Could not uncompress database - exited $?\r\n";
25 }
26 print "GeoIP database updated. Old copy is at " . $ipdb . "." . $date
27 . "\r\n";
28 }
29 else {
30 croak "Fetch failed - try again later?\r\n";
31 }
32 }
33 else {
34 croak "You don't appear to have a valid GeoIP database installed..\r\n";
35 }
36

admin@fedoraproject.org
ViewVC Help
Powered by ViewVC 1.1.2