fetch GeoLite2-Country.mmdb.gz after 30 days of file age
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -29,6 +29,7 @@ mods/*/*.mdb
|
||||
/*.mdb
|
||||
/*.exe
|
||||
thirdparty/download/*
|
||||
*.mmdb.gz
|
||||
|
||||
# backup files by various editors
|
||||
*~
|
||||
|
||||
Binary file not shown.
3
Makefile
3
Makefile
@@ -318,6 +318,7 @@ osx-dependencies: cli-dependencies
|
||||
@ $(CP_R) thirdparty/download/osx/*.dll.config .
|
||||
|
||||
dependencies: $(os-dependencies)
|
||||
@./thirdparty/fetch-geoip-db.sh
|
||||
|
||||
all-dependencies: cli-dependencies windows-dependencies osx-dependencies
|
||||
|
||||
@@ -353,7 +354,7 @@ install-core: default
|
||||
@$(CP_R) mods/modchooser "$(DATA_INSTALL_DIR)/mods/"
|
||||
|
||||
@$(INSTALL_DATA) "global mix database.dat" "$(DATA_INSTALL_DIR)/global mix database.dat"
|
||||
@$(INSTALL_DATA) "GeoLite2-Country.mmdb" "$(DATA_INSTALL_DIR)/GeoLite2-Country.mmdb"
|
||||
@$(INSTALL_DATA) "GeoLite2-Country.mmdb.gz" "$(DATA_INSTALL_DIR)/GeoLite2-Country.mmdb.gz"
|
||||
@$(INSTALL_DATA) AUTHORS "$(DATA_INSTALL_DIR)/AUTHORS"
|
||||
@$(INSTALL_DATA) COPYING "$(DATA_INSTALL_DIR)/COPYING"
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ FILES=('OpenRA.Game.exe' 'OpenRA.Editor.exe' 'OpenRA.Utility.exe' \
|
||||
'OpenRA.Renderer.Sdl2.dll' 'OpenRA.Renderer.Null.dll' \
|
||||
'lua' 'glsl' 'mods/common' 'mods/ra' 'mods/cnc' 'mods/d2k' 'mods/modchooser' \
|
||||
'AUTHORS' 'COPYING' 'README.html' 'CONTRIBUTING.html' 'DOCUMENTATION.html' 'CHANGELOG.html' \
|
||||
'global mix database.dat' 'GeoLite2-Country.mmdb')
|
||||
'global mix database.dat' 'GeoLite2-Country.mmdb.gz')
|
||||
|
||||
echo "Copying files..."
|
||||
for i in "${FILES[@]}"; do
|
||||
|
||||
@@ -89,7 +89,7 @@ Section "Game" GAME
|
||||
File "${SRCDIR}\MaxMind.GeoIP2.dll"
|
||||
File "${SRCDIR}\Newtonsoft.Json.dll"
|
||||
File "${SRCDIR}\RestSharp.dll"
|
||||
File "${SRCDIR}\GeoLite2-Country.mmdb"
|
||||
File "${SRCDIR}\GeoLite2-Country.mmdb.gz"
|
||||
File "${SRCDIR}\eluant.dll"
|
||||
File "${DEPSDIR}\soft_oal.dll"
|
||||
File "${DEPSDIR}\SDL2.dll"
|
||||
@@ -205,7 +205,7 @@ Function ${UN}Clean
|
||||
Delete $INSTDIR\MaxMind.GeoIP2.dll
|
||||
Delete $INSTDIR\Newtonsoft.Json.dll
|
||||
Delete $INSTDIR\RestSharp.dll
|
||||
Delete $INSTDIR\GeoLite2-Country.mmdb
|
||||
Delete $INSTDIR\GeoLite2-Country.mmdb.gz
|
||||
Delete $INSTDIR\KopiLua.dll
|
||||
Delete $INSTDIR\soft_oal.dll
|
||||
Delete $INSTDIR\SDL2.dll
|
||||
|
||||
19
thirdparty/fetch-geoip-db.sh
vendored
Executable file
19
thirdparty/fetch-geoip-db.sh
vendored
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Die on any error for Travis CI to automatically retry:
|
||||
set -e
|
||||
|
||||
download_dir="${0%/*}/download"
|
||||
mkdir -p "${download_dir}"
|
||||
cd "${download_dir}"
|
||||
|
||||
filename="GeoLite2-Country.mmdb.gz"
|
||||
|
||||
# Database does not exist or is older than 30 days.
|
||||
if [[ ! -e $filename ]] || [[ -n $(find . -name $filename -mtime +30 -print) ]]; then
|
||||
rm -f $filename
|
||||
echo "Updating GeoIP country database from MaxMind."
|
||||
curl -s -L -O http://geolite.maxmind.com/download/geoip/database/$filename
|
||||
cp $filename ../..
|
||||
fi
|
||||
|
||||
8
thirdparty/fetch-thirdparty-deps.ps1
vendored
8
thirdparty/fetch-thirdparty-deps.ps1
vendored
@@ -130,4 +130,12 @@ if (!(Test-Path "Eluant.dll"))
|
||||
(New-Object System.Net.WebClient).DownloadFile("https://github.com/OpenRA/Eluant/releases/download/20140425/Eluant.dll", $target)
|
||||
}
|
||||
|
||||
if (!(Test-Path "GeoLite2-Country.mmdb.gz") -Or (((get-date) - (get-item "GeoLite2-Country.mmdb").LastWriteTime) -gt (new-timespan -days 30)))
|
||||
{
|
||||
echo "Updating GeoIP country database from MaxMind."
|
||||
$target = Join-Path $pwd.ToString() "GeoLite2-Country.mmdb.gz"
|
||||
(New-Object System.Net.WebClient).DownloadFile("http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz", $target)
|
||||
cp GeoLite2-Country.mmdb.gz ..\..
|
||||
}
|
||||
|
||||
cd ..
|
||||
|
||||
Reference in New Issue
Block a user