-
-
Save jjhesk/0730839f700512e73bd3e67ab6ecbcf9 to your computer and use it in GitHub Desktop.
auto link
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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