geoip-bootstraps
Recent changes to the licensing of MaxMind's GeoIP databases requires users to create a login even to download the free products, as well as to update them. This is incredibly inconvenient, as it breaks any platform that a developer intends to deploy in an operational state.
In this repository are several methods to streamline the process of obtaining and updating the databases without circumventing the requirement for a MaxMind account and license key.
These approaches are intended to be customized and integrated to your own platform or application workflow. These scripts are not intended to be used by themselves. I'm pretty sure they won't help you at all in a standalone capacity.
Prerequisites
- The
geoipupdate
tool must be installed. - A MaxMind account is required. Sign up for a free account here.
- A MaxMind license key is required. After signing up for and into your MaxMind account, generate a license key here. Note that you'll need to know the version of the
geoipupdate
utility you'll be using.
Method 1: User-initiated Download
This method uses an artificially created file containing a valid GeoIP database shell but no content. Most GeoIP-using tools will accept this at startup but you should test this on your own. After starting with the empty GeoIP database files, users run a script which requests their MaxMind user id and license key, then creates a GeoIP.conf
file and downloads the databases. This requires the geoipupdate
tool is installed and configured to use the GeoIP.conf
file that will be generated. (You will likely need to adjust paths in the script for it to work on your platform.) Subsequent runs of the geoipupdate
tool will retrieve new copies of the GeoIP database files using the same user id and license key.
- Place the
geoip_bootstrap.sh
andGeoIP.conf.default
files on the system. - Install the included empty.mmdb file wherever a GeoIP database is required.
- Tailor the
geoip_bootstrap.sh
script'sgeoip_conf_template
andgeoip_conf_target
variables. - Ensure the system does not have a
GeoIP.conf
file in the location specified bygeoip_conf_target
. - Direct users to run
geoip_bootstrap.sh
after booting the platform when GeoIP features are required. - Before distributing the platform, ensure any GeoIP databases are replaced with
empty.mmdb
and theGeoIP.conf
file has been deleted.
Method 2: Boot-initiated Download
This method uses systemd
to run a script at boot time which requests the user's GeoIP user id and license key, creates a GeoIP.conf
file, then retrieves the GeoIP databases before completing the boot process.
NOTICE: This method WILL hang the boot process for 30 seconds before continuing without creating a GeoIP.conf
file or downloading the MaxMind databases.
- Place the
geoip_bootstrap.sh
andGeoIP.conf.default
files on the system. - Install the included empty.mmdb file wherever a GeoIP database is required. (Optional but recommended.)
- Tailor the
geoip_bootstrap.sh
script'sgeoip_conf_template
andgeoip_conf_target
variables. - Ensure the system does not have a
GeoIP.conf
file in the location specified bygeoip_conf_target
. - Place the
geoip_bootstrap.service
file on the system, usually in the/etc/systemd/system/
directory. - Tailor the
geoip_bootstrap.service
file'sBefore=
andRequiredBy=
parameters as needed to to ensure proper service startup order. - Run
systemctl daemon-reload
. - Run
systemctl enable geoip_bootstrap.service
. - During the next boot cycle, the script will interrupt the boot process, setting up GeoIP.
- Before distributing the platform, ensure any GeoIP databases are replaced with
empty.mmdb
and theGeoIP.conf
file has been deleted.