Skip to content

Instantly share code, notes, and snippets.

@revenkroz
Last active July 22, 2024 15:16
Show Gist options
  • Save revenkroz/cff91f350b5c90f5e740977c53d06ea0 to your computer and use it in GitHub Desktop.
Save revenkroz/cff91f350b5c90f5e740977c53d06ea0 to your computer and use it in GitHub Desktop.
Script to download MaxMind DB and extract it immediately
#!/bin/sh
export GEOIP_EDITION='GeoLite2-Country'
export GEOIP_LICENCE_KEY='secret_licence_key'
export GEOIP_TMP_FILE=geoip.tar.gz
curl -sSL "https://download.maxmind.com/app/geoip_download?edition_id=${GEOIP_EDITION}&license_key=${GEOIP_LICENCE_KEY}&suffix=tar.gz" > $GEOIP_TMP_FILE && \
tar -xzf $GEOIP_TMP_FILE --wildcards "*/${GEOIP_EDITION}.mmdb" --strip=1 && \
rm $GEOIP_TMP_FILE
@tkoop
Copy link

tkoop commented May 6, 2024

MaxMind now uses redirects, so you have to add the "-L" option to curl, like this:

curl -sSL "https://download.maxmind.com/app/geoip_dow...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment