#!/bin/bash # Install Ollama on the system disk and point its model store at the model folder. Safe to re-run. . "$(dirname "$0")/lib.sh" if ! have ollama; then say "installing Ollama with its official installer (https://ollama.com/install.sh)" curl -fsSL https://ollama.com/install.sh | sh || die "the Ollama installer failed" fi mkdir -p "$MODELS_DIR/ollama" chown -R ollama:ollama "$MODELS_DIR/ollama" mkdir -p "$MODELS_DIR/ollama/blobs" chown ollama:ollama "$MODELS_DIR/ollama/blobs" grant_ollama_blobs # settings live in a drop-in so Ollama upgrades never overwrite them mkdir -p /etc/systemd/system/ollama.service.d { echo "[Unit]" mountpoint -q "$MODELS_DIR" && echo "RequiresMountsFor=$MODELS_DIR" cat < /etc/systemd/system/ollama.service.d/wxch.conf systemctl daemon-reload systemctl enable ollama >/dev/null 2>&1 || true systemctl restart ollama i=0 until curl -fsS http://127.0.0.1:11434/api/version >/dev/null 2>&1; do i=$((i+1)); [ "$i" -lt 30 ] || die "Ollama did not come up; see: journalctl -u ollama -n 50" sleep 1 done say "Ollama $(curl -fsS http://127.0.0.1:11434/api/version) is serving from $MODELS_DIR/ollama"