Files
maps-saas/infrastructure/scripts/import-regions.sh
T

53 lines
1.7 KiB
Bash

#!/bin/bash
# Script to import Egypt and Jordan OSM data into the PostGIS database
# نص برمجي لاستيراد بيانات مصر والأردن إلى قاعدة البيانات
set -e
DATA_DIR="./infrastructure/osm-data"
DB_USER=${POSTGRES_USER:-mapuser}
DB_NAME=${POSTGRES_DB:-mapdb}
echo "🌍 Starting MENA Regional Data Import..."
echo "🌍 البدء في استيراد البيانات الإقليمية..."
# 1. Check for files
if [ ! -f "$DATA_DIR/jordan-latest.osm.pbf" ]; then
echo "❌ Jordan PBF missing. Please run setup-osm.sh first."
exit 1
fi
if [ ! -f "$DATA_DIR/egypt-latest.osm.pbf" ]; then
echo "📥 Downloading Egypt OSM PBF..."
curl -L https://download.geofabrik.de/africa/egypt-latest.osm.pbf -o "$DATA_DIR/egypt-latest.osm.pbf"
fi
# 2. Detect Docker Compose Command
if command -v docker-compose &> /dev/null; then
DOKCER_COMPOSE="docker-compose"
else
DOKCER_COMPOSE="docker compose"
fi
echo "🐳 Using $DOKCER_COMPOSE..."
# 3. Import Jordan (Append)
echo "🇯🇴 Importing Jordan data (Append mode)..."
$DOKCER_COMPOSE --profile import run --rm osm-import osm2pgsql \
--append --slim --cache 1000 \
--database "$DB_NAME" --host db --user "$DB_USER" \
/data/jordan-latest.osm.pbf
# 4. Import Egypt (Append)
echo "🇪🇬 Importing Egypt data (Append mode)..."
$DOKCER_COMPOSE --profile import run --rm osm-import osm2pgsql \
--append --slim --cache 1000 \
--database "$DB_NAME" --host db --user "$DB_USER" \
/data/egypt-latest.osm.pbf
echo "✅ Import complete. Restarting tile and routing services..."
$DOKCER_COMPOSE restart martin routing
echo "🚀 MENA Regional mapping is now live!"
echo "🚀 تم تفعيل خرائط المنطقة بنجاح!"