From b26f806002ab5e6f86870e84dc00127d2d63b54e Mon Sep 17 00:00:00 2001 From: Patrick Britton Date: Sun, 1 Feb 2026 12:35:08 -0600 Subject: [PATCH] Update GeoIP setup script to automatically download real database from GitHub mirror --- go-backend/scripts/setup-geoip.sh | 50 ++++++++++++++++++------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/go-backend/scripts/setup-geoip.sh b/go-backend/scripts/setup-geoip.sh index 2fe3036..73da506 100644 --- a/go-backend/scripts/setup-geoip.sh +++ b/go-backend/scripts/setup-geoip.sh @@ -18,26 +18,34 @@ sudo chown patrick:patrick "$GEOIP_DIR" echo "Downloading GeoLite2-Country database..." cd "$GEOIP_DIR" -# Use curl to download the database (you'll need a MaxMind account for this) -# For now, we'll create a placeholder - you should replace this with actual download -echo "Note: You need to sign up for a free MaxMind account to download the GeoLite2 database" -echo "Visit: https://dev.maxmind.com/geoip/geolite2-free-geolocation-data" -echo "" -echo "After getting your license key, download with:" -echo "curl -v 'https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&license_key=YOUR_LICENSE_KEY&suffix=tar.gz' | tar xz --strip-components=1 -C ." -echo "" +# Download the free GeoLite2-Country database +echo "Downloading from MaxMind..." +wget -O GeoLite2-Country.tar.gz "https://github.com/P3TERX/GeoLite.mmdb/raw/download/GeoLite2-Country.mmdb.gz" 2>/dev/null || { + echo "Primary download failed, trying alternative source..." + # Alternative source - GitHub mirror + wget -O GeoLite2-Country.mmdb.gz "https://raw.githubusercontent.com/P3TERX/GeoLite.mmdb/download/GeoLite2-Country.mmdb.gz" || { + echo "All downloads failed. Please manually download GeoLite2-Country.mmdb" + exit 1 + } +} -# Create a placeholder file for now (this won't work but allows the service to start) -echo "Creating placeholder database file (you should replace this with the real database)" -cat > placeholder.txt << 'EOF' -This is a placeholder file. You need to download the actual GeoLite2-Country.mmdb file -from MaxMind and place it here: /opt/sojorn/geoip/GeoLite2-Country.mmdb +# Extract if we got a gz file +if [ -f "GeoLite2-Country.mmdb.gz" ]; then + echo "Extracting database..." + gunzip GeoLite2-Country.mmdb.gz + echo "Database extracted successfully!" +elif [ -f "GeoLite2-Country.tar.gz" ]; then + echo "Extracting tar.gz file..." + tar xzf GeoLite2-Country.tar.gz --strip-components=1 + rm GeoLite2-Country.tar.gz + echo "Database extracted successfully!" +fi -Steps: -1. Sign up for free account at https://dev.maxmind.com/geoip/geolite2-free-geolocation-data -2. Get your license key -3. Download: curl -v 'https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&license_key=YOUR_LICENSE_KEY&suffix=tar.gz' | tar xz --strip-components=1 -C . -EOF - -echo "Setup complete. Please download the actual GeoIP database as described above." -echo "The service will start but geographic filtering will be disabled until the database is installed." +# Verify the database file exists +if [ -f "$DATABASE_FILE" ]; then + echo "✓ GeoIP database installed successfully at: $DATABASE_FILE" + echo "File size: $(du -h "$DATABASE_FILE" | cut -f1)" +else + echo "✗ Failed to install GeoIP database" + exit 1 +fi