#!/usr/bin/env bash
# ONLINE preparation only: pull the model into ./models. Safe to rerun (resumes).
. "$(dirname "$0")/common.sh"

started=0
if ! is_running; then
  nohup setsid "$OLLAMA" serve >>"$LOG" 2>&1 </dev/null &
  echo $! >"$PIDFILE"; started=1
  wait_ready
fi
OLLAMA_NO_CLOUD= "$OLLAMA" pull "$MODEL"
"$OLLAMA" show "$MODEL"
"$OLLAMA" show --license "$MODEL" >"$BASE/MODEL-LICENSE.txt"
[[ $started == 1 ]] && "$BASE/stop.sh"
