Make Digital Beautiful.

und schnell

Update geolocation databases for Crowdsec WordPress

Bash Script:


# Set the path to the directory where the database is stored

export GEOIP_EDITION='GeoLite2-Country'
export GEOIP_TMP_FILE=geoip.tar.gz

curl -sS "${GEOIP_EDITION}&license_key=${GEOIP_LICENCE_KEY}&suffix=tar.gz" > $GEOIP_TMP_FILE && \
tar -xzf $GEOIP_TMP_FILE --wildcards "*/${GEOIP_EDITION}.mmdb" --strip=1                                                                                && \
mv GeoLite2-Country.mmdb $DATABASE_DIR/GeoLite2-Country.mmdb

Make the script executable:

chmod +x

Let Cron run it twice a week

0 6 * * 3,6 /path/to/ >> /path/to/geo.log 2>&1

This runs the script “At 06:00 on Wednesday and Saturday.
For people like me, there is a nice tool to generate the right time here ⇾

Maxmind relating Updates:

GeoLite2 databases are free IP geolocation databases comparable to, but less accurate than, MaxMind’s GeoIP2 databases. The GeoLite2 Country, City, and ASN databases are updated twice weekly, every Tuesday and Friday. GeoLite2 data is also available as a web service in the GeoLite2 Country and GeoLite2 City web services. Users of the GeoLite2 web services are limited to 1000 IP address lookups per service per day.

GeoLite2 Free Geolocation Data | MaxMind Developer Portal