#!/bin/bash # THIS SCRIPT DOES NOT WORK RIGHT NOW # The script is fine, it just needs the modelfiles to be written with reference # to the models folder relative to the host system, rather than inside the # container. We're using ./modelfiles/.loadmodels.sh instead right now. modelfiles="$(ls ./modelfiles/)" models="$(ollama list | tr -s ' ' | cut -f 1 | tail -n +2)" for model in $(echo "$models"); do if ! [[ $modelfiles == *"$model"* ]]; then echo -n "Running: '" echo "ollama rm \"$model\"'" ollama rm "$model" fi done cd ./modelfiles for modelfile in ./*; do echo -n "Running: '" echo "ollama create \"$(basename $modelfile)\" -f \"$modelfile\"'" ollama create "$(basename $modelfile)" -f "$modelfile" done