adding ollama installer
This commit is contained in:
53
scripts/ollama_detect_and_link.sh
Executable file
53
scripts/ollama_detect_and_link.sh
Executable 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."
|
||||
Reference in New Issue
Block a user