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,53 @@
#!/usr/bin/env bash
set -euo pipefail
echo "🔍 Detecting Ollama model directories and linking into OLLAMA_MODELS"
# Load env if available
if [ -f "$HOME/.bashrc" ]; then
set +u
# shellcheck disable=SC1091
source "$HOME/.bashrc" || true
set -u
fi
OLLAMA_MODELS="${OLLAMA_MODELS:-$HOME/models/ollama}"
mkdir -p "$OLLAMA_MODELS"
candidates=(
"$HOME/.ollama/models"
"$HOME/.local/share/ollama/models"
"/var/lib/ollama/models"
"/usr/local/var/ollama/models"
"$HOME/.ollama"
)
linked=0
for cand in "${candidates[@]}"; do
if [ -d "$cand" ]; then
# skip empty directories
if [ -z "$(ls -A "$cand" 2>/dev/null)" ]; then
echo " Found $cand but it's empty — skipping"
continue
fi
name=$(basename "$cand")
dest="$OLLAMA_MODELS/$name"
if [ -e "$dest" ]; then
echo " Destination exists: $dest — skipping"
continue
fi
ln -sfn "$cand" "$dest"
echo "✅ Linked $cand$dest"
linked=$((linked+1))
fi
done
if [ $linked -eq 0 ]; then
echo "⚠️ No existing Ollama model directories detected in common locations."
echo "You can place models in: $OLLAMA_MODELS or run: pull_ollama_model <model-ref> (see scripts/ollama_tmux.sh)"
else
echo "🎉 Completed linking ($linked). Verify with: ls -la $OLLAMA_MODELS"
fi
echo "Done."