From 28636c0b9beff062799bb4ca896337dcf2b1918d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Diot?= Date: Wed, 1 May 2024 14:57:14 +0200 Subject: [PATCH] Update MMDB download and error handling in update-mmdb.sh --- misc/update-mmdb.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/misc/update-mmdb.sh b/misc/update-mmdb.sh index f282d564f..cd1c56cca 100755 --- a/misc/update-mmdb.sh +++ b/misc/update-mmdb.sh @@ -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