Skip to content

Instantly share code, notes, and snippets.

@jjhesk
Created March 27, 2026 14:25
Show Gist options
  • Select an option

  • Save jjhesk/0730839f700512e73bd3e67ab6ecbcf9 to your computer and use it in GitHub Desktop.

Select an option

Save jjhesk/0730839f700512e73bd3e67ab6ecbcf9 to your computer and use it in GitHub Desktop.
auto link
cat > ~/update-llama-symlinks.sh << 'EOF'
#!/bin/bash
# ================================================
# Auto-create clean symlinks from Ollama blobs
# Works with current Ollama (no --no-trunc needed)
# Run this after any ollama pull / rm / update
# ================================================
OLLAMA_BLOBS="/Users/fadacai/.ollama/models/blobs"
TARGET_DIR="$HOME/models/llama"
mkdir -p "$TARGET_DIR"
cd "$TARGET_DIR"
echo "πŸ”„ Updating symlinks from Ollama blobs..."
# Remove old symlinks first
find . -type l -delete 2>/dev/null
# Get list of models from ollama list
ollama list | tail -n +2 | while read -r line; do
# Extract model name (first column)
model=$(echo "$line" | awk '{print $1}')
if [[ -n "$model" ]]; then
# Get the FROM blob path from Modelfile
blob_path=$(ollama show --modelfile "$model" 2>/dev/null | grep '^FROM ' | awk '{print $2}')
if [[ -n "$blob_path" && -f "$blob_path" ]]; then
# Create clean name: replace : with - and clean invalid characters
clean_name=$(echo "$model" | sed 's/:/-/g' | sed 's/[^a-zA-Z0-9._-]/-/g')
symlink_name="${clean_name}.gguf"
ln -sf "$blob_path" "$symlink_name"
echo "βœ… Linked: $model β†’ $symlink_name"
else
echo "⚠️ Skipped (no blob found): $model"
fi
fi
done
echo ""
echo "πŸŽ‰ Done! Current symlinks in $TARGET_DIR:"
ls -lh "$TARGET_DIR" | grep '\.gguf$'
echo ""
echo "Tip: Restart your llama-server router to pick up changes:"
echo "launchctl unload ~/Library/LaunchAgents/com.morpheumllm.llama-server.router.plist"
echo "launchctl load ~/Library/LaunchAgents/com.morpheumllm.llama-server.router.plist"
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment