Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GeoIP data update to the automatic build system #524

Merged
merged 2 commits into from Aug 27, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 30 additions & 0 deletions support/buildbot/package.pl
Expand Up @@ -4,7 +4,9 @@
use strict;
use Cwd;
use File::Basename;
use File::stat;
use Net::FTP;
use Time::localtime;

my ($ftp_file, $ftp_host, $ftp_user, $ftp_pass, $ftp_path);

Expand Down Expand Up @@ -34,6 +36,34 @@
#Switch to the output folder.
chdir(Build::PathFormat('../../../OUTPUT'));

my $needNewGeoIP = 1;
if (-e '../GeoLite2-Country.tar.gz')
{
my $fileModifiedTime = stat('../GeoLite2-Country.tar.gz')->mtime;
my $fileModifiedMonth = localtime($fileModifiedTime)->mon;
my $currentMonth = localtime->mon;
my $thirtyOneDays = 60 * 60 * 24 * 31;

# GeoIP file only updates once per month
if ($currentMonth == $fileModifiedMonth || (time() - $fileModifiedTime) < $thirtyOneDays)
{
$needNewGeoIP = 0;
}
}

if ($needNewGeoIP)
{
print "Downloading GeoLite2-Country.mmdb...\n";
system('wget -q -O ../GeoLite2-Country.tar.gz http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.tar.gz');
}
else
{
print "Reusing existing GeoLite2-Country.mmdb\n";
}

system('gunzip -c ../GeoLite2-Country.tar.gz > packages/base/addons/amxmodx/data/GeoLite2-Country.mmdb');


my (@packages,@mac_exclude);
@packages = ('base', 'cstrike', 'dod', 'esf', 'ns', 'tfc', 'ts');
@mac_exclude = ('esf', 'ns', 'ts');
Expand Down