#!/bin/sh set -e REGION="${OSRM_REGION:-connecticut-latest}" PBF="/data/${REGION}.osm.pbf" URL="https://download.geofabrik.de/north-america/us/${REGION}.osm.pbf" MIN_BYTES=10000000 # 10 MB — a valid PBF is always larger than this # Check if a complete file already exists if [ -f "$PBF" ]; then SIZE=$(wc -c < "$PBF") if [ "$SIZE" -gt "$MIN_BYTES" ]; then echo "[osrm-download] Map data already present ($(( SIZE / 1024 / 1024 )) MB), skipping download." exit 0 else echo "[osrm-download] Existing file is too small (${SIZE} bytes), re-downloading..." rm -f "$PBF" fi fi echo "[osrm-download] Downloading ${REGION} map data from Geofabrik..." curl --fail -L --progress-bar -o "$PBF" "$URL" || { rm -f "$PBF"; echo "[osrm-download] Download failed."; exit 1; } SIZE=$(wc -c < "$PBF") echo "[osrm-download] Download complete ($(( SIZE / 1024 / 1024 )) MB)."