Add script to update mmdb files + update mmdb files

This commit is contained in:
Théophile Diot 2024-04-02 13:14:43 +01:00
parent 5af1c63083
commit 113ba8222a
No known key found for this signature in database
GPG key ID: 248FEA4BAE400D06
3 changed files with 39 additions and 0 deletions

39
misc/update-mmdb.sh Executable file
View file

@ -0,0 +1,39 @@
#!/bin/bash
# This script downloads the latest GeoLite2 databases from dbip.com and updates the existing ones.
cd ../src/bw/misc || cd src/bw/misc || exit 1
# Download the latest GeoLite2 databases
curl -o asn.mmdb.gz "https://download.db-ip.com/free/dbip-asn-lite-$(date +%Y-%m).mmdb.gz"
# shellcheck disable=SC2181
if [ $? -ne 0 ]; then
echo "❌ Failed to download the ASN database."
exit 1
fi
curl -o country.mmdb.gz "https://download.db-ip.com/free/dbip-country-lite-$(date +%Y-%m).mmdb.gz"
# shellcheck disable=SC2181
if [ $? -ne 0 ]; then
echo "❌ Failed to download the country database."
exit 1
fi
# Decompress the downloaded databases
gunzip -f asn.mmdb.gz
# shellcheck disable=SC2181
if [ $? -ne 0 ]; then
echo "❌ Failed to decompress the ASN database."
exit 1
fi
gunzip -f country.mmdb.gz
# shellcheck disable=SC2181
if [ $? -ne 0 ]; then
echo "❌ Failed to decompress the country database."
exit 1
fi
echo "✅ Updated the GeoLite2 databases."

Binary file not shown.

Binary file not shown.