adding ollama installer

This commit is contained in:
Kenji Morishige
2026-02-23 19:53:49 -06:00
parent 0fc1b3cba0
commit 074ab05908
5 changed files with 358 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
#!/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"