#!/bin/bash # Setup script for GeoIP database # This downloads the GeoLite2-Country database from MaxMind set -e GEOIP_DIR="/opt/sojorn/geoip" DATABASE_FILE="$GEOIP_DIR/GeoLite2-Country.mmdb" echo "Setting up GeoIP database for geographic filtering..." # Create directory if it doesn't exist sudo mkdir -p "$GEOIP_DIR" sudo chown patrick:patrick "$GEOIP_DIR" # Download the GeoLite2-Country database 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 "" # 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 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."