Files
dotfiles/scripts/bootstrap_ollama_linux.sh
2026-02-23 19:53:49 -06:00

41 lines
1.6 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/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 <file.deb>"
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"