Repository Public
1#!/usr/bin/env bash2# =============================================================================3# SP BOUCHER | INFRASTRUCTURE & AUTOMATION4# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project : ORIX Cosmos8# File : DataPipeline/ephemeris/fetch_kernels.sh9# Module : DataPipeline10# Repository : https://git.spboucher.ai/orix-cosmos11# Project Website : https://www.orixlab.dev12# Created : 2026-11-2413# Last Modified : 2026-11-2414#15# Author : Simon-Pierre Boucher16# Position : Professor of Finance17# Institution : Université du Québec en Outaouais (UQO)18# Organization : SP Boucher19# Website : https://spboucher.ai20# Git : https://git.spboucher.ai21#22# Preferred Contact: support@spboucher.ai23# Technical Contact: dev@spboucher.ai24# Security/Admin : admin@spboucher.ai25#26# Copyright (c) 202627# Simon-Pierre Boucher28# All rights reserved where applicable. This file is governed by the29# applicable project license, copyright notices and relevant law.30# Existing third-party rights and notices remain unaffected.31#32# License : None specified (no license file in this repository)33#34# Do not embed credentials, private keys, access tokens,35# certificates or confidential personal information.36#37# =============================================================================38# END OF SP BOUCHER SOURCE HEADER39# =============================================================================4041# ORIX Cosmos42# File: DataPipeline/ephemeris/fetch_kernels.sh43# Description: Downloads the generic NAIF kernels of the core ephemeris pack (DE440s SPK, leap seconds, PCK, GM) with resumable curl, records SHA-256, and assembles Resources/Packs/core-ephemeris with its manifest.44#45# Author: Simon-Pierre Boucher46# Contact: contact@spboucher.ai47#48# Usage: DataPipeline/ephemeris/fetch_kernels.sh49# Network: naif.jpl.nasa.gov only (official public archive). No personal data is sent; the User-Agent is generic.50# Licence of the files: see Documentation/modules/CosmosEphemeris.md (NAIF "Kernels Redistribution" rule: unmodified51# kernels may be redistributed). The files are copied byte for byte; nothing is modified.52set -euo pipefail5354HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"55ROOT="$(cd "$HERE/../.." && pwd)"56RAW="$ROOT/DataPipeline/raw/ephemeris"57PACK="$ROOT/Resources/Packs/core-ephemeris"58UA="orix-cosmos-pipeline/1.0"59BASE="https://naif.jpl.nasa.gov/pub/naif/generic_kernels"6061# name|url62FILES=(63 "de440s.bsp|$BASE/spk/planets/de440s.bsp"64 "naif0012.tls|$BASE/lsk/naif0012.tls"65 "pck00011.tpc|$BASE/pck/pck00011.tpc"66 "gm_de440.tpc|$BASE/pck/gm_de440.tpc"67)6869mkdir -p "$RAW" "$PACK"70: > "$RAW/SHA256SUMS.tmp"71for entry in "${FILES[@]}"; do72 name="${entry%%|*}"; url="${entry#*|}"73 dest="$RAW/$name"74 # Remote size (to decide whether a partial file must be resumed).75 remote_size="$(curl -sSIL -A "$UA" "$url" | awk 'tolower($1)=="content-length:" {v=$2} END {gsub("\r","",v); print v}')"76 local_size=077 [ -f "$dest" ] && local_size="$(stat -f %z "$dest" 2>/dev/null || stat -c %s "$dest")"78 if [ -n "$remote_size" ] && [ "$local_size" = "$remote_size" ]; then79 echo "ok $name ($local_size bytes, already complete)"80 else81 echo "fetch $name <- $url"82 curl -fsSL --retry 5 --retry-delay 3 -C - -A "$UA" -o "$dest" "$url"83 local_size="$(stat -f %z "$dest" 2>/dev/null || stat -c %s "$dest")"84 if [ -n "$remote_size" ] && [ "$local_size" != "$remote_size" ]; then85 echo "error: $name is $local_size bytes, server announces $remote_size" >&2; exit 186 fi87 fi88 sum="$(shasum -a 256 "$dest" | awk '{print $1}')"89 echo "$sum $name" >> "$RAW/SHA256SUMS.tmp"90 sleep 191done92mv "$RAW/SHA256SUMS.tmp" "$RAW/SHA256SUMS"93date -u +%Y-%m-%d > "$RAW/RETRIEVED"9495for entry in "${FILES[@]}"; do96 name="${entry%%|*}"97 cp -p "$RAW/$name" "$PACK/$name"98done99100python3 -I "$HERE/build_core_manifest.py" "$ROOT"101echo "pack $PACK"102