From ed9ccc48c0720c50bbad89b18047856bcd2c487d Mon Sep 17 00:00:00 2001 From: MeaTLoTioN Date: Thu, 3 Apr 2025 11:59:48 +0100 Subject: [PATCH] make install file betterer --- install.sh | 58 +++++++++++++++++++++++++++++++++++++++++++++ startrek/install.sh | 4 ---- 2 files changed, 58 insertions(+), 4 deletions(-) create mode 100755 install.sh delete mode 100755 startrek/install.sh diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..39012fc --- /dev/null +++ b/install.sh @@ -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 diff --git a/startrek/install.sh b/startrek/install.sh deleted file mode 100755 index 7142737..0000000 --- a/startrek/install.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -# Install all the files -for file in *; do ollama create ${file} -f ${file}; done