#!/usr/bin/env bash set -euo pipefail echo "🔧 Ollama macOS bootstrap — starting" # Load environment (MODEL_ROOT, OLLAMA_MODELS) # Temporarily disable "nounset" when sourcing user shell files to avoid # failures from system /etc/bashrc referencing undefined vars like PS1. if [ -f "$HOME/.bashrc" ]; then set +u # shellcheck disable=SC1091 source "$HOME/.bashrc" || true set -u fi : "${OLLAMA_MODELS:=$HOME/models/ollama}" mkdir -p "$OLLAMA_MODELS" if command -v ollama >/dev/null 2>&1; then echo "✅ ollama already installed: $(ollama version 2>/dev/null || echo 'unknown')" else if command -v brew >/dev/null 2>&1; then echo "🍺 Installing ollama via Homebrew..." brew update || true brew install ollama || { echo "⚠️ Homebrew install failed. See https://ollama.com/docs/install" exit 1 } echo "✅ ollama installed" else echo "⚠️ Homebrew not found. Install Homebrew first: https://brew.sh" echo "Then re-run this script: $0" exit 2 fi fi echo "📁 Ensuring model directory exists: $OLLAMA_MODELS" mkdir -p "$OLLAMA_MODELS" echo "✅ macOS Ollama bootstrap complete." echo "Next steps: run scripts/ollama_tmux.sh to start the server in tmux, and place models under $OLLAMA_MODELS"