#!/bin/bash # ============================================ # OSM Data Download Script for GeoEdu Service # ============================================ # # WICHTIG: Dieses Script startet einen Download von ca. 4.4 GB! # Nur nach expliziter Freigabe ausfuehren! # # Quelle: Geofabrik (offizieller OSM-Mirror) # Lizenz: ODbL (Open Database License) # Attribution: © OpenStreetMap contributors # # Nutzung: # ./download_osm.sh [--dry-run] # # ============================================ set -e # Configuration DATA_DIR="${OSM_DATA_DIR:-/app/data/osm}" GEOFABRIK_URL="https://download.geofabrik.de/europe/germany-latest.osm.pbf" GEOFABRIK_MD5_URL="https://download.geofabrik.de/europe/germany-latest.osm.pbf.md5" OUTPUT_FILE="germany-latest.osm.pbf" # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color echo -e "${YELLOW}============================================${NC}" echo -e "${YELLOW}GeoEdu Service - OSM Data Download${NC}" echo -e "${YELLOW}============================================${NC}" echo "" echo -e "Quelle: ${GREEN}Geofabrik${NC}" echo -e "Datei: ${GREEN}Germany PBF${NC}" echo -e "Groesse: ${YELLOW}~4.4 GB${NC}" echo -e "Lizenz: ${GREEN}ODbL (Open Database License)${NC}" echo -e "Attribution: ${GREEN}© OpenStreetMap contributors${NC}" echo "" # Check for dry-run mode if [[ "$1" == "--dry-run" ]]; then echo -e "${YELLOW}[DRY-RUN] Kein Download wird durchgefuehrt.${NC}" echo "" echo "Wuerde herunterladen von:" echo " $GEOFABRIK_URL" echo "" echo "Nach:" echo " $DATA_DIR/$OUTPUT_FILE" echo "" exit 0 fi # Confirm download echo -e "${RED}ACHTUNG: Download startet ~4.4 GB Daten!${NC}" echo "" read -p "Download starten? (j/N) " -n 1 -r echo "" if [[ ! $REPLY =~ ^[JjYy]$ ]]; then echo "Download abgebrochen." exit 1 fi # Create data directory mkdir -p "$DATA_DIR" cd "$DATA_DIR" # Download MD5 checksum first echo "" echo -e "${GREEN}[1/3] Lade MD5-Pruefsumme herunter...${NC}" curl -L -o "${OUTPUT_FILE}.md5" "$GEOFABRIK_MD5_URL" # Download OSM data echo "" echo -e "${GREEN}[2/3] Lade OSM-Daten herunter (~4.4 GB)...${NC}" echo " Dies kann je nach Internetverbindung 5-60 Minuten dauern." echo "" # Use wget with resume support if command -v wget &> /dev/null; then wget -c -O "$OUTPUT_FILE" "$GEOFABRIK_URL" else curl -L -C - -o "$OUTPUT_FILE" "$GEOFABRIK_URL" fi # Verify checksum echo "" echo -e "${GREEN}[3/3] Verifiziere MD5-Pruefsumme...${NC}" if md5sum -c "${OUTPUT_FILE}.md5"; then echo "" echo -e "${GREEN}✓ Download erfolgreich!${NC}" echo "" echo "Datei: $DATA_DIR/$OUTPUT_FILE" echo "Groesse: $(du -h "$OUTPUT_FILE" | cut -f1)" echo "" echo -e "${YELLOW}Naechster Schritt:${NC}" echo " ./import_osm.sh # OSM in PostGIS importieren" echo " ./generate_tiles.sh # PMTiles generieren" else echo "" echo -e "${RED}✗ MD5-Pruefsumme stimmt nicht ueberein!${NC}" echo "Bitte Download erneut starten." exit 1 fi echo "" echo -e "${YELLOW}============================================${NC}" echo -e "${YELLOW}Download abgeschlossen${NC}" echo -e "${YELLOW}============================================${NC}"