#!/usr/bin/env bash set -euo pipefail echo "🔧 Ollama Linux 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 echo "â„šī¸ Attempting to install ollama on Linux" if command -v apt-get >/dev/null 2>&1; then echo "Using apt to install prerequisites..." sudo apt-get update -y || true sudo apt-get install -y ca-certificates curl gnupg lsb-release || true echo "âš ī¸ Please follow the official ollama Linux install instructions if a package is not available: https://ollama.com/docs/install" echo "If you have a .deb from Ollama, install it with: sudo dpkg -i " elif command -v dnf >/dev/null 2>&1; then echo "Using dnf; please refer to Ollama docs for distro-specific instructions: https://ollama.com/docs/install" else echo "âš ī¸ Could not detect package manager. Please install ollama manually. See: https://ollama.com/docs/install" fi fi echo "📁 Ensuring model directory exists: $OLLAMA_MODELS" mkdir -p "$OLLAMA_MODELS" echo "✅ Linux Ollama bootstrap complete." echo "Next steps: run scripts/ollama_tmux.sh to start the server in tmux, and place models under $OLLAMA_MODELS"