- horoscope-api: Swiss Ephemeris natal charts, timezone/place resolution, POST /v1/natal and POST /v1/synastry - backend: users with roles, email/password and Google login, saved charts, synastries and invites, analyses with credit ledger, public shares, admin - shared crates: astro-engine, db (migrations), horoscope-client, service-kit - docker-compose with postgres, legacy Java project for reference Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
92 lines
4.1 KiB
Bash
Executable File
92 lines
4.1 KiB
Bash
Executable File
#!/usr/bin/env sh
|
|
# Downloads and prepares every external dependency of the backend services, so
|
|
# that the services themselves never need network access at runtime.
|
|
#
|
|
# vendor/swisseph/ Swiss Ephemeris C sources (compiled into swisseph-sys)
|
|
# data/ephe/ Swiss Ephemeris data files (*.se1)
|
|
# data/zoneinfo/ IANA tzdb compiled WITH backzone (per-country pre-1970 history)
|
|
# data/geonames/ GeoNames place database (CC BY 4.0)
|
|
#
|
|
# Usage: scripts/fetch-deps.sh [target-root] (default: repository root)
|
|
set -eu
|
|
|
|
ROOT="${1:-$(cd "$(dirname "$0")/.." && pwd)}"
|
|
|
|
SWISSEPH_VERSION="${SWISSEPH_VERSION:-v2.10.3bfinal}"
|
|
SWISSEPH_EPHE_FILES="${SWISSEPH_EPHE_FILES:-sepl_18.se1 semo_18.se1 seas_18.se1}"
|
|
TZDB_VERSION="${TZDB_VERSION:-2026f}"
|
|
GEONAMES_CITIES="${GEONAMES_CITIES:-cities500}"
|
|
# Countries whose complete populated-place list is loaded (small villages too).
|
|
GEONAMES_FULL_COUNTRIES="${GEONAMES_FULL_COUNTRIES:-HU}"
|
|
|
|
TMP="$(mktemp -d)"
|
|
trap 'rm -rf "$TMP"' EXIT
|
|
|
|
fetch() { curl -fsSL --retry 3 -o "$2" "$1"; }
|
|
log() { echo "==> $*"; }
|
|
|
|
# --- Swiss Ephemeris sources -------------------------------------------------
|
|
if [ ! -f "$ROOT/vendor/swisseph/VERSION" ] || [ "$(cat "$ROOT/vendor/swisseph/VERSION")" != "$SWISSEPH_VERSION" ]; then
|
|
log "Swiss Ephemeris $SWISSEPH_VERSION sources"
|
|
fetch "https://github.com/aloistr/swisseph/archive/refs/tags/$SWISSEPH_VERSION.tar.gz" "$TMP/swisseph.tar.gz"
|
|
mkdir -p "$TMP/swisseph"
|
|
tar -xzf "$TMP/swisseph.tar.gz" -C "$TMP/swisseph" --strip-components=1
|
|
rm -rf "$ROOT/vendor/swisseph"
|
|
mkdir -p "$ROOT/vendor/swisseph"
|
|
cp "$TMP"/swisseph/*.c "$TMP"/swisseph/*.h "$TMP"/swisseph/LICENSE* "$ROOT/vendor/swisseph/"
|
|
echo "$SWISSEPH_VERSION" > "$ROOT/vendor/swisseph/VERSION"
|
|
fi
|
|
|
|
# --- Swiss Ephemeris data files ----------------------------------------------
|
|
mkdir -p "$ROOT/data/ephe"
|
|
for f in $SWISSEPH_EPHE_FILES; do
|
|
if [ ! -s "$ROOT/data/ephe/$f" ]; then
|
|
log "ephemeris file $f"
|
|
fetch "https://raw.githubusercontent.com/aloistr/swisseph/$SWISSEPH_VERSION/ephe/$f" "$ROOT/data/ephe/$f"
|
|
fi
|
|
done
|
|
|
|
# --- IANA time zone database (with backzone) ---------------------------------
|
|
if [ ! -f "$ROOT/data/zoneinfo/VERSION" ] || [ "$(cat "$ROOT/data/zoneinfo/VERSION")" != "$TZDB_VERSION" ]; then
|
|
log "tzdb $TZDB_VERSION (compiled with backzone)"
|
|
mkdir -p "$TMP/tz"
|
|
fetch "https://data.iana.org/time-zones/releases/tzcode$TZDB_VERSION.tar.gz" "$TMP/tzcode.tar.gz"
|
|
fetch "https://data.iana.org/time-zones/releases/tzdata$TZDB_VERSION.tar.gz" "$TMP/tzdata.tar.gz"
|
|
tar -xzf "$TMP/tzcode.tar.gz" -C "$TMP/tz"
|
|
tar -xzf "$TMP/tzdata.tar.gz" -C "$TMP/tz"
|
|
# PACKRATDATA/PACKRATLIST keep the pre-1970 history of every zone listed in
|
|
# zone.tab instead of linking it to a "similar" zone (e.g. Oslo -> Berlin).
|
|
make -s -C "$TMP/tz" DESTDIR="$TMP/tzout" PACKRATDATA=backzone PACKRATLIST=zone.tab install >/dev/null
|
|
ZI="$(find "$TMP/tzout" -type f -name zone.tab -path '*zoneinfo*' | head -1)"
|
|
rm -rf "$ROOT/data/zoneinfo"
|
|
cp -R "$(dirname "$ZI")" "$ROOT/data/zoneinfo"
|
|
echo "$TZDB_VERSION" > "$ROOT/data/zoneinfo/VERSION"
|
|
fi
|
|
|
|
# --- GeoNames ----------------------------------------------------------------
|
|
GN="$ROOT/data/geonames"
|
|
mkdir -p "$GN"
|
|
if [ ! -s "$GN/$GEONAMES_CITIES.txt" ]; then
|
|
log "GeoNames $GEONAMES_CITIES"
|
|
fetch "https://download.geonames.org/export/dump/$GEONAMES_CITIES.zip" "$TMP/cities.zip"
|
|
unzip -o -q "$TMP/cities.zip" -d "$GN"
|
|
fi
|
|
for cc in $GEONAMES_FULL_COUNTRIES; do
|
|
if [ ! -s "$GN/full_$cc.txt" ]; then
|
|
log "GeoNames full populated-place list for $cc"
|
|
fetch "https://download.geonames.org/export/dump/$cc.zip" "$TMP/$cc.zip"
|
|
unzip -o -q "$TMP/$cc.zip" "$cc.txt" -d "$TMP"
|
|
# keep populated places only (feature class P)
|
|
awk -F '\t' '$7 == "P"' "$TMP/$cc.txt" > "$GN/full_$cc.txt"
|
|
fi
|
|
done
|
|
for f in countryInfo.txt admin1CodesASCII.txt; do
|
|
if [ ! -s "$GN/$f" ]; then
|
|
log "GeoNames $f"
|
|
fetch "https://download.geonames.org/export/dump/$f" "$GN/$f"
|
|
fi
|
|
done
|
|
date -u +%Y-%m-%d > "$GN/DOWNLOADED"
|
|
|
|
log "done: $ROOT/vendor, $ROOT/data"
|