Skip to content

Commit

Permalink
Maxmind requires a license_key for all downloads now
Browse files Browse the repository at this point in the history
  • Loading branch information
ross committed Apr 30, 2020
1 parent 19c4143 commit d2fdc0e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions script/download-geoip
Original file line number Diff line number Diff line change
@@ -1,37 +1,43 @@
#!/bin/bash

set -e
set -o pipefail

# TODO: use tempdirs and clean up after ourselves

cd "$(dirname $0)"/..
ROOT=$(pwd)

if [ -z $MAXMIND_LICENSE_KEY ]; then
echo "MAXMIND_LICENSE_KEY env var must be defined to continue"
exit 1
fi

out="./data/GeoLite2-ASN.mmdb"
base=$(basename $out .mmdb)
if [ ! -f $out ]; then
echo "Downloading $base"
curl -sS "https://download.maxmind.com/app/geoip_download?edition_id=$base&suffix=tar.gz" | \
curl -sS "https://download.maxmind.com/app/geoip_download?edition_id=$base&suffix=tar.gz&license_key=$MAXMIND_LICENSE_KEY" | \
(cd data && tar xz && mv $base*/$base.mmdb ./)
fi

out="./data/asns.csv"
base="GeoLite2-ASN-CSV"
if [ ! -f $out ]; then
echo "Downloading $base"
curl -sS "https://download.maxmind.com/app/geoip_download?edition_id=$base&suffix=zip" > data/$base.zip
curl -sS "https://download.maxmind.com/app/geoip_download?edition_id=$base&suffix=zip&license_key=$MAXMIND_LICENSE_KEY" > data/$base.zip
(cd data && unzip -q -o $base.zip && cut -d , -f 2- $base*/*.csv | sort -n | uniq > asns.csv)
fi

if [ -z $MAXMIND_LICENSE_KEY ]; then
if [ -z $MAXMIND_PAID ]; then
out="./data/GeoLite2-City.mmdb"
base=$(basename $out .mmdb)
if [ ! -f $out ]; then
echo ""
echo "NOTICE: MAXMIND_LICENSE_KEY env variable not defined, downloading $base"
echo ""
echo "Downloading $base"
curl -sS "https://download.maxmind.com/app/geoip_download?edition_id=$base&suffix=tar.gz" | \
curl -sS "https://download.maxmind.com/app/geoip_download?edition_id=$base&suffix=tar.gz&license_key=$MAXMIND_LICENSE_KEY" | \
(cd data && tar xz && mv $base*/$base.mmdb ./)
fi
else
Expand Down

0 comments on commit d2fdc0e

Please sign in to comment.