Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GeoIP API
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eclipse Foundation
IT
APIs
GeoIP API
Merge requests
!4
Fixed CI/CD
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Fixed CI/CD
fixci
into
master
Overview
1
Commits
2
Changes
5
Merged
Christopher Guindon
requested to merge
fixci
into
master
5 years ago
Overview
1
Commits
2
Changes
5
Expand
Created by: mbarbero
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
527a81dd
2 commits,
3 years ago
5 files
+
135
−
55
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
5
Search (e.g. *.vue) (Ctrl+P)
bin/maxmind.sh
+
32
−
37
Options
#/bin/bash
#! /usr/bin/env bash
# Bash strict-mode
set -o errexit
set -o nounset
set -o pipefail
IFS=$'\n\t'
## Required due to JVM busybox usage
IS_BB=0
agnostic_cp () {
if [ $IS_BB == 1 ]; then
cp
-f
$2
$1
cp -f
"${2}" "${1}"
else
cp
-ut
$1
$2
cp -ut
"${1}" "${2}"
fi
}
## Check sys + args
if
[
-z
"
$
1
"
]
;
then
echo
"An argument for location of DB files needs to be set"
if [ -z "$
{1}
" ]; then
echo "An argument for location of DB files needs to be set"
exit 1
fi
if
[[
`
busybox
--help
`
=
~
"command not found"
]]
;
then
IS_BB
=
0
else
IS_BB
=
1
fi
## Start
echo
"Starting MaxMind data retrieval!"
BINARY_BIN
=
"
$1
/bin"
mkdir -p "${1}/bin"
mkdir -p "${1}/db"
pushd "${1:-"."}" || exit 1
echo "Getting data from MaxMind"
wget
"https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country-CSV.zip"
wget
"https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.tar.gz"
wget
"https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz"
curl -sSL "https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.tar.gz" | tar zxv -C bin --wildcards '*.mmdb'
curl -sSL "https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz" | tar zxv -C bin --wildcards '*.mmdb'
curl -sSL "https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country-CSV.zip" -o GeoLite2-Country-CSV.zip
unzip GeoLite2-Country-CSV.zip
rm -vf GeoLite2-Country-CSV.zip
echo
"Extracting CSV data"
## Copy the Country CSV data to a location on the drive
unzip
-o
GeoLite2-Country-CSV.zip
echo
"Copying data to
$1
/db to be uploaded"
DIR
=
$(
pwd
)
COUNTRY_DIR
=
$(
find
$DIR
-maxdepth
1
-type
d
-name
"GeoLite2-Country*"
)
mkdir
-p
$1
/db
agnostic_cp
"
$1
/db"
"
$COUNTRY_DIR
/GeoLite2-Country-Locations-en.csv
$COUNTRY_DIR
/GeoLite2-Country-Blocks*"
echo
"Extracting MaxMind GeoIP binaries"
echo "Moving MaxMind GeoIP databases"
cp -vf GeoLite2-Country**/GeoLite2-Country-Locations-en.csv db/
cp -vf GeoLite2-Country**/GeoLite2-Country-Blocks* db/
rm -rvf GeoLite2-Country*
echo "Moving MaxMind GeoIP binaries"
## Extract the binary geoIP databases
mkdir
-p
$BINARY_BIN
tar
-C
$BINARY_BIN
-xzvf
GeoLite2-Country.tar.gz
--wildcards
'*.mmdb'
tar
-C
$BINARY_BIN
-xzvf
GeoLite2-City.tar.gz
--wildcards
'*.mmdb'
(
cd
$BINARY_BIN
&&
find
.
-mindepth
1
-type
f
-exec
mv
-f
{}
$BINARY_BIN
\;
&&
find
.
-mindepth
1
-type
d
-exec
rm
-rf
{}
\;
)
echo
"Cleaning up extra files"
## Cleanup
rm
-rf
$COUNTRY_DIR
rm
GeoLite2-Country-CSV.zip
rm
GeoLite2-Country.tar.gz
rm
GeoLite2-City.tar.gz
mv -vf bin/GeoLite2-**/GeoLite2-C*.mmdb bin/
rm -rvf bin/GeoLite2-City_*
rm -rvf bin/GeoLite2-Country_*
popd || exit 1
\ No newline at end of file
Loading