├── README.md ├── syncmodels └── syncmodelsforlmstudio /README.md: -------------------------------------------------------------------------------- 1 | # Just a collection of scripts I wrote for folks 2 | 3 | - **syncmodelsforlmstudio** - updated for the new format of LM Studio models. I still don't think this is right. I'll deal with it soon. 4 | - **syncmodels** - the original version I mention in the video. 5 | -------------------------------------------------------------------------------- /syncmodels: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # syncs models from ollama to somewhere else 3 | # 4 | # Base directories 5 | base_dir=~/.ollama/models 6 | manifest_dir=$base_dir/manifests/registry.ollama.ai 7 | blob_dir=$base_dir/blobs 8 | publicmodels_dir=~/publicmodels/mattw/lmstudio 9 | 10 | # Remove all existing symbolic links from publicmodels directory 11 | find "$publicmodels_dir" -type l -exec rm {} + 12 | 13 | # Create publicmodels directory if it doesn't exist 14 | mkdir -p "$publicmodels_dir" 15 | 16 | # Use find to get all files under the 'model' directories 17 | find "$manifest_dir" -mindepth 3 -maxdepth 3 -type f | while IFS= read -r file; do 18 | user=$(basename "$(dirname "$(dirname "$file")")" | sed 's/^registry\.ollama\.ai/ollama/') 19 | model=$(basename "$(dirname "$file")") 20 | tag=$(basename "$file") 21 | 22 | digest=$(jq -r '.layers[] | select(.mediaType == "application/vnd.ollama.image.model") | .digest' "$file") 23 | 24 | # Create symbolic link 25 | ln -s "$blob_dir/$digest" "$publicmodels_dir/$user-$model-$tag.bin" 26 | 27 | # Print the user, model, and tag 28 | echo "$user - $model:$tag" 29 | done 30 | 31 | 32 | -------------------------------------------------------------------------------- /syncmodelsforlmstudio: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | base_dir=~/.ollama/models 4 | manifest_dir=$base_dir/manifests/registry.ollama.ai 5 | blob_dir=$base_dir/blobs 6 | publicmodels_dir=~/publicmodels/mattw/lmstudio 7 | 8 | find "$publicmodels_dir" -type l -exec rm {} + 9 | 10 | mkdir -p "$publicmodels_dir" 11 | 12 | find "$manifest_dir" -type f -mindepth 3 -maxdepth 3 | while IFS= read -r file; do 13 | user=$(basename "$(dirname "$(dirname "$file")")" | sed 's/^registry\.ollama\.ai/ollama/') 14 | model=$(basename "$(dirname "$file")") 15 | tag=$(basename "$file") 16 | 17 | digest=$(jq -r '.layers[] | select(.mediaType == "application/vnd.ollama.image.model") | .digest' "$file") 18 | digest="${digest//:/-}" 19 | mkdir -p "$publicmodels_dir/$user/$model/" 20 | ln -s "$blob_dir/$digest" "$publicmodels_dir/$user/$model/$model-$tag.gguf" 21 | 22 | echo "$user - $model:$tag" 23 | done 24 | 25 | 26 | 27 | 28 | --------------------------------------------------------------------------------