make install file betterer
This commit is contained in:
parent
84059c2288
commit
ed9ccc48c0
58
install.sh
Executable file
58
install.sh
Executable file
@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
usage(){
|
||||
echo "Usage: $(basename $0) {model file|all|list}"
|
||||
exit 1
|
||||
}
|
||||
|
||||
installAll(){
|
||||
echo "Installing ALL model files..."
|
||||
# Install all the files
|
||||
for file in */*; do
|
||||
res=$(checkExists $(basename $file))
|
||||
if [[ $? -lt 1 ]]; then
|
||||
echo "Installing model: $(basename $file)"
|
||||
ollama create $(basename ${file}) -f ${file}
|
||||
else
|
||||
echo "$(basename $file) already exists, skipping."
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
installFile(){
|
||||
res=$(checkExists $(basename $1))
|
||||
if [[ $? -lt 1 ]]; then
|
||||
if [[ -f $1 ]]; then
|
||||
echo "Installing model file: $1"
|
||||
ollama create $(basename $1) -f $1
|
||||
else
|
||||
echo "File not found, aborting!"
|
||||
fi
|
||||
else
|
||||
echo "$(basename $1) already exists, skipped."
|
||||
fi
|
||||
}
|
||||
|
||||
listFiles(){
|
||||
[[ $1 ]] && CAT=$1 || CAT="*"
|
||||
for file in ${CAT}/*; do
|
||||
echo "$file"
|
||||
done
|
||||
}
|
||||
|
||||
checkExists(){
|
||||
models="$(ollama list|awk '{print $1}'|sed 's/:.*//g'|grep $1)"
|
||||
if [[ $models ]]; then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
[[ ${#1} -lt 1 ]] && usage
|
||||
|
||||
case $1 in
|
||||
[aA][lL][lL]) installAll ;;
|
||||
[lL][iI][sS][tT]) listFiles $2 ;;
|
||||
*) installFile $1 ;;
|
||||
esac
|
@ -1,4 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Install all the files
|
||||
for file in *; do ollama create ${file} -f ${file}; done
|
Loading…
x
Reference in New Issue
Block a user