-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathollama_setup.sh
executable file
·72 lines (61 loc) · 1.67 KB
/
ollama_setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
# We define the folder (in $PATH), where the ollama binary will be placed
BIN_DIR=${HOME}/.local/bin
LIB_DIR=${HOME}/.local/lib
mkdir -p ${BIN_DIR}
mkdir -p ${LIB_DIR}
ollama_start() {
echo "Downloading and launching ollama..."
curl -L https://ollama.com/download/ollama-linux-amd64.tgz -o ollama-linux-amd64.tgz
tar -xzf ollama-linux-amd64.tgz
sleep 2
echo "coucou"
mv bin/* ${BIN_DIR}
mv lib/* ${LIB_DIR}
chmod +x ${BIN_DIR}/ollama
ls ${BIN_DIR}/ollama
echo "coucou2"
sleep 2
ollama serve &
ollama pull llama3.2
#&> /dev/null &
echo -e "Finished: \o/"
}
#https://github.com/ollama/ollama/releases/tag/v0.5.8-rc7
get_models() {
MODELS_FILE="models.list"
MODELS_DEFAULT="orca-mini"
# We check if the models file exists
if [ ! -f ${MODELS_FILE} ]; then
echo "File ${MODELS_FILE} not found, ${MODELS_DEFAULT} used by default."
echo ${MODELS_DEFAULT} > ${MODELS_FILE}
fi
# Loop through each line and pull model
while IFS= read -r line; do
echo "Pulling ${line} model..."
ollama pull "${line}" > /dev/null
echo -e "Finished: \033[32m✔\033[0m\n"
done < ${MODELS_FILE}
}
# We start ollama, and wait for it to respond
ollama_start
if [ $? -ne 0 ]; then
echo -e "\nError during ollama setup."
exit 1
fi
count=0
MAX_TIME=10
while ! pgrep -x "ollama" > /dev/null; do
if [ ${count} -lt ${MAX_TIME} ]; then
sleep 1
count=$((count+1))
else
echo "Application 'ollama' did not launch within 10 seconds."
exit 1
fi
done
get_models
if [ $? -ne 0 ]; then
echo -e "\nError during models downloading."
exit 1
fi