You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functionupdate_ollama_modelsecho"Fetching list of Ollama models..."set -l jobs
ollama list | tail -n +2 |whileread -l line
set model_name (echo $line| awk '{print $1}')
iftest -n "$model_name"echo"Attempting to update model: $model_name"
ollama pull $model_name&set -a jobs$last_pidecho"Started update for model: $model_name"elseecho"No model name extracted from line: $line"
end
end
forjobin$jobswait$job
end
ollama list | tail -n +2 | awk -F"\t"'{printf $1 "\t" $3 "\t" $4 "\t" $5 RS}'echo"Ollama models update complete."
end
Fish function To update Ollama models for linux
functionupdate_ollama_modelsecho"Updating Ollama client..."
curl -fsSL https://ollama.com/install.sh | sh
if not type -q ollama
echo"Ollama command could not be found. Please check the installation."return 1
end
set -l ollama_proc (ps aux | grep '[o]llama serve')
iftest -z "$ollama_proc"echo"Ollama is not running. Starting Ollama serve..."
ollama serve &elseecho"Ollama serve is already running."
end
echo"Fetching list of Ollama models..."set -l jobs
ollama list | tail -n +2 |whileread -l line
set model_name (echo $line| awk '{print $1}')
iftest -n "$model_name"echo"Attempting to update model: $model_name"
ollama pull $model_name&set -a jobs$last_pidecho"Started update for model: $model_name"elseecho"No model name extracted from line: $line"
end
end
forjobin$jobswait$job
end
ollama list | tail -n +2 | awk -F"\t"'{printf $1 "\t" $3 "\t" $4 "\t" $5 RS}'echo"Ollama models update complete."
end
if ! command -v ollama &> /dev/null; then
echo "Ollama command could not be found. Please check the installation." >> $LOGFILE
exit 1
else
echo "Ollama command exists." >> $LOGFILE
fi
ollama_proc=$(pgrep -f "ollama serve")
if [ -z "$ollama_proc" ]; then
echo "Ollama is not running. Starting Ollama serve..." >> $LOGFILE
ollama serve >> $LOGFILE 2>&1 &
echo "Ollama serve started." >> $LOGFILE
else
echo "Ollama serve is already running." >> $LOGFILE
fi
echo "Fetching list of Ollama models..." >> $LOGFILE
jobs=()
while read -r line; do
model_name=$(echo "$line" | awk '{print $1}')
if [ -n "$model_name" ]; then
echo "Attempting to update model: $model_name" >> $LOGFILE
ollama pull "$model_name" >> $LOGFILE 2>&1 &
jobs+=($!)
echo "Started update for model: $model_name" >> $LOGFILE
else
echo "No model name extracted from line: $line" >> $LOGFILE
fi
done < <(ollama list | tail -n +2)
How about an sh scirpt which can log?
#!/bin/bash
LOGFILE="/path_whatewayouwant/ollama_update.log"
Write output to the log file
echo "Starting Ollama update script..." $(date) >> $LOGFILE
echo "Updating Ollama client..." >> $LOGFILE
curl -fsSL https://ollama.com/install.sh | sh >> $LOGFILE 2>&1
if ! command -v ollama &> /dev/null; then
echo "Ollama command could not be found. Please check the installation." >> $LOGFILE
exit 1
else
echo "Ollama command exists." >> $LOGFILE
fi
ollama_proc=$(pgrep -f "ollama serve")
if [ -z "$ollama_proc" ]; then
echo "Ollama is not running. Starting Ollama serve..." >> $LOGFILE
ollama serve >> $LOGFILE 2>&1 &
echo "Ollama serve started." >> $LOGFILE
else
echo "Ollama serve is already running." >> $LOGFILE
fi
echo "Fetching list of Ollama models..." >> $LOGFILE
jobs=()
while read -r line; do
model_name=$(echo "$line" | awk '{print $1}')
if [ -n "$model_name" ]; then
echo "Attempting to update model: $model_name" >> $LOGFILE
ollama pull "$model_name" >> $LOGFILE 2>&1 &
jobs+=($!)
echo "Started update for model: $model_name" >> $LOGFILE
else
echo "No model name extracted from line: $line" >> $LOGFILE
fi
done < <(ollama list | tail -n +2)
for job in "${jobs[@]}"; do
wait "$job"
done
ollama list | tail -n +2 | awk -F"\t" '{printf $1 "\t" $3 "\t" $4 "\t" $5 RS}' >> $LOGFILE
echo "Ollama models update complete." >> $LOGFILE