#!/bin/bash # First ingestion on the production node (run ON the node, from ~/apps/satelliteindex). Idempotent. # CelesTrak refuses a second download of the same GP group within 2 h (HTTP 403 "has not updated") — the connector treats it as # unchanged. If a local snapshot exists in ~/satelliteindex-data/seed/ (active.json, satcat.csv) it is used for the very first run. set -euo pipefail cd "$(dirname "$0")/.." export PATH="/opt/homebrew/opt/postgresql@17/bin:/opt/homebrew/bin:$PATH" export DATABASE_URL=${DATABASE_URL:-postgresql+asyncpg://satelliteindex:satelliteindex@127.0.0.1:5432/satelliteindex} export REDIS_URL=${REDIS_URL:-redis://127.0.0.1:6379/4} export SI_DATA_DIR=${SI_DATA_DIR:-$HOME/satelliteindex-data} export SI_LOG_JSON=0 SI=.venv/bin/si SEED=$SI_DATA_DIR/seed $SI migrate | tail -1 $SI seed | tail -1 n=$(psql "postgresql://satelliteindex:satelliteindex@127.0.0.1:5432/satelliteindex" -Atc "select count(*) from satellites") echo "satellites in db: $n" if [ "$n" -lt 1000 ] && [ -s "$SEED/satcat.csv" ]; then echo "seeding SATCAT from local snapshot"; $SI run celestrak_satcat --file satcat.csv="$SEED/satcat.csv" || true fi $SI run celestrak_satcat || true gp=$(psql "postgresql://satelliteindex:satelliteindex@127.0.0.1:5432/satelliteindex" -Atc "select count(*) from orbital_state") if [ "$gp" -lt 1000 ] && [ -s "$SEED/active.json" ]; then echo "seeding GP from local snapshot"; $SI run celestrak_gp --file active="$SEED/active.json" || true fi $SI run celestrak_gp || true $SI run celestrak_groups || true $SI run derived_analytics $SI stats