#!/usr/bin/env bash set -euo pipefail ROOT_OVERRIDE="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" export ROOT_OVERRIDE # shellcheck disable=SC1091 source "${ROOT_OVERRIDE}/scripts/common.sh" init_log bootstrap-native print_header "bootstrap-native: START" need_cmd curl need_cmd python need_cmd ollama load_env check_for_legacy_docker_ollama log "bootstrap-native: waiting for Ollama API at ${OLLAMA_URL}" wait_for_ollama_api "$OLLAMA_URL" 120 || fail "Ollama API not reachable at ${OLLAMA_URL}" 40 ok "bootstrap-native: Ollama API reachable" log "bootstrap-native: pulling base model ${BASE_MODEL}" ollama pull "${BASE_MODEL}" if [[ -n "${EXTRA_MODELS}" ]]; then for m in ${EXTRA_MODELS}; do log "bootstrap-native: pulling extra model ${m}" ollama pull "$m" done fi tmp="$(mktemp)" trap 'rm -f "$tmp"' EXIT render_modelfile "$tmp" log "bootstrap-native: building expert model ${EXPERT_MODEL}" ollama create "${EXPERT_MODEL}" -f "$tmp" tags="$(fetch_tags)" printf '%s' "$tags" | is_json || fail "/api/tags did not return valid JSON" 41 model_in_tags "$EXPERT_MODEL" "$tags" || fail "expert model missing after bootstrap: ${EXPERT_MODEL}" 42 ok "bootstrap-native: expert model available: ${EXPERT_MODEL}" warmup_sqlai print_footer "bootstrap-native: END status=OK log=${LOG_FILE}"