SPB Git

Repository Public

01-download.sh 3.0 KB 65 lines shellscript

1#!/bin/bash2# =============================================================================3#                  SP BOUCHER | INFRASTRUCTURE & AUTOMATION4#             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project          : KA Maps Engine8# File             : server/pipeline/01-download.sh9# Module           : server10# Repository       : https://git.spboucher.ai/ka-maps-engine11# Created          : 2026-12-0112# Last Modified    : 2026-12-0113#14# Author           : Simon-Pierre Boucher15# Position         : Professor of Finance16# Institution      : Université du Québec en Outaouais (UQO)17# Organization     : SP Boucher18# Website          : https://spboucher.ai19# Git              : https://git.spboucher.ai20#21# Preferred Contact: support@spboucher.ai22# Technical Contact: dev@spboucher.ai23# Security/Admin   : admin@spboucher.ai24#25# Copyright (c) 202626# Simon-Pierre Boucher27# All rights reserved where applicable. This file is governed by the28# applicable project license, copyright notices and relevant law.29# Existing third-party rights and notices remain unaffected.30#31# License          : None specified (no license file in this repository)32#33# Do not embed credentials, private keys, access tokens,34# certificates or confidential personal information.35#36# =============================================================================37# END OF SP BOUCHER SOURCE HEADER38# =============================================================================3940# Télécharge les extraits Geofabrik (Québec + voisins) et vérifie leur somme MD5 publiée.41# Les fichiers arrivent sous un nom temporaire : un extrait n'est remplacé que s'il est complet et vérifié.42. "$(dirname "$0")/env.sh"43G=https://download.geofabrik.de/north-america44D=$KM_SRC/osm45REGIONS=${KM_REGIONS:-"canada/quebec canada/ontario canada/new-brunswick canada/newfoundland-and-labrador canada/nova-scotia canada/prince-edward-island canada/nunavut us/maine us/new-hampshire us/vermont us/new-york"}46mkdir -p "$D"; cd "$D"47fetch() {48  local u=$1 f; f=$(basename "$u")-latest.osm.pbf49  curl -fsSL --retry 5 --retry-delay 20 -o "$f.md5.new" "$G/$u-latest.osm.pbf.md5"50  if [ -f "$f" ] && [ -f "$f.md5" ] && cmp -s "$f.md5" "$f.md5.new"; then51    log "$f inchangé"; rm -f "$f.md5.new"; return 052  fi53  curl -fsSL --retry 5 --retry-delay 20 -C - -o "$f.part" "$G/$u-latest.osm.pbf"54  if [ "$(md5sum "$f.part" | cut -d' ' -f1)" != "$(cut -d' ' -f1 "$f.md5.new")" ]; then55    log "ERREUR somme MD5 de $f"; rm -f "$f.part" "$f.md5.new"; return 156  fi57  mv "$f.part" "$f"; mv "$f.md5.new" "$f.md5"58  log "$f téléchargé et vérifié ($(stat -c %s "$f") octets)"59}60# Geofabrik limite le débit par connexion : trois téléchargements de front.61printf '%s\n' $REGIONS | xargs -P 3 -I{} bash -c ". '$KM_PIPE/env.sh'; $(declare -f fetch); G=$G; cd $D; fetch {}"62curl -fsSL -o quebec.poly "$G/canada/quebec.poly"63sha256sum ./*-latest.osm.pbf > SHA256SUMS64log "téléchargements terminés"65
Files main
Menu

Theme