Updated geolite2-db-update.sh script to fix issue where the download of the database files would save to the wrong folder so the extract wouldn't work

This commit is contained in:
Phil 2025-01-25 21:48:06 +00:00
parent 7fe7c60963
commit 06263e30b4

View File

@ -2,7 +2,7 @@
# Define constants
BASE_URL="https://download.maxmind.com/geoip/databases"
AUTH="YOUR_ACCOUNT_ID:YOUR_LICENSE_KEY"
AUTH="OUR_ACCOUNT_ID:YOUR_LICENSE_KEY"
OUTPUT_DIR="$(dirname "$0")/geolite2/db"
CITY_FILE="GeoLite2-City"
ASN_FILE="GeoLite2-ASN"
@ -20,13 +20,14 @@ process_file() {
echo "Processing $file_name..."
curl -O -J -L -u "$AUTH" "$BASE_URL/$file_name/download?suffix=tar.gz"
# Download the .tar.gz file to the output directory
curl -o "$OUTPUT_DIR/$file_name.tar.gz" -J -L -u "$AUTH" "$BASE_URL/$file_name/download?suffix=tar.gz"
# Extract the .tar.gz file
tar -xzf "$file_name.tar.gz" --wildcards --strip-components=1 -C "$target_dir" "*/$file_name.mmdb"
# Extract the .tar.gz file into the target directory
tar -xzf "$OUTPUT_DIR/$file_name.tar.gz" --wildcards --strip-components=1 -C "$target_dir" "*/$file_name.mmdb"
# Clean up the downloaded tar.gz file
rm -f "$file_name.tar.gz"
rm -f "$OUTPUT_DIR/$file_name.tar.gz"
echo "$file_name processed and placed in $target_dir"
}
@ -37,4 +38,3 @@ process_file "$ASN_FILE" "$OUTPUT_DIR/asn"
process_file "$COUNTRY_FILE" "$OUTPUT_DIR/country"
echo "All files processed successfully."