Update MMDB download and error handling in update-mmdb.sh

This commit is contained in:
Théophile Diot 2024-05-01 14:57:14 +02:00
parent 08e4a6709f
commit 28636c0b9b
No known key found for this signature in database
GPG key ID: 248FEA4BAE400D06

View file

@ -13,6 +13,12 @@ if [ $? -ne 0 ]; then
exit 1
fi
content_head="$(head -n 2 asn.mmdb.gz)"
if [[ "$content_head" =~ "404 Not Found" ]]; then
echo "❌ The ASN database is not available for the current month for the moment."
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
@ -20,6 +26,12 @@ if [ $? -ne 0 ]; then
exit 1
fi
content_head="$(head -n 2 country.mmdb.gz)"
if [[ "$content_head" =~ "404 Not Found" ]]; then
echo "❌ The country database is not available for the current month for the moment."
exit 1
fi
# Decompress the downloaded databases
gunzip -f asn.mmdb.gz