Update GeoIP setup script to automatically download real database from GitHub mirror

This commit is contained in:
Patrick Britton 2026-02-01 12:35:08 -06:00
parent 5782563236
commit b26f806002

View file

@ -18,26 +18,34 @@ sudo chown patrick:patrick "$GEOIP_DIR"
echo "Downloading GeoLite2-Country database..." echo "Downloading GeoLite2-Country database..."
cd "$GEOIP_DIR" cd "$GEOIP_DIR"
# Use curl to download the database (you'll need a MaxMind account for this) # Download the free GeoLite2-Country database
# For now, we'll create a placeholder - you should replace this with actual download echo "Downloading from MaxMind..."
echo "Note: You need to sign up for a free MaxMind account to download the GeoLite2 database" wget -O GeoLite2-Country.tar.gz "https://github.com/P3TERX/GeoLite.mmdb/raw/download/GeoLite2-Country.mmdb.gz" 2>/dev/null || {
echo "Visit: https://dev.maxmind.com/geoip/geolite2-free-geolocation-data" echo "Primary download failed, trying alternative source..."
echo "" # Alternative source - GitHub mirror
echo "After getting your license key, download with:" wget -O GeoLite2-Country.mmdb.gz "https://raw.githubusercontent.com/P3TERX/GeoLite.mmdb/download/GeoLite2-Country.mmdb.gz" || {
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 "All downloads failed. Please manually download GeoLite2-Country.mmdb"
echo "" exit 1
}
}
# Create a placeholder file for now (this won't work but allows the service to start) # Extract if we got a gz file
echo "Creating placeholder database file (you should replace this with the real database)" if [ -f "GeoLite2-Country.mmdb.gz" ]; then
cat > placeholder.txt << 'EOF' echo "Extracting database..."
This is a placeholder file. You need to download the actual GeoLite2-Country.mmdb file gunzip GeoLite2-Country.mmdb.gz
from MaxMind and place it here: /opt/sojorn/geoip/GeoLite2-Country.mmdb 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: # Verify the database file exists
1. Sign up for free account at https://dev.maxmind.com/geoip/geolite2-free-geolocation-data if [ -f "$DATABASE_FILE" ]; then
2. Get your license key echo "✓ GeoIP database installed successfully at: $DATABASE_FILE"
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 . echo "File size: $(du -h "$DATABASE_FILE" | cut -f1)"
EOF else
echo "✗ Failed to install GeoIP database"
echo "Setup complete. Please download the actual GeoIP database as described above." exit 1
echo "The service will start but geographic filtering will be disabled until the database is installed." fi