-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·39 lines (33 loc) · 950 Bytes
/
Copy pathentrypoint.sh
File metadata and controls
executable file
·39 lines (33 loc) · 950 Bytes
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
#!/usr/bin/env bash
set -e
OLLAMA_HOME="/root/.ollama"
MODELS_DIR="${OLLAMA_HOME}/models"
if [[ -n "${OFFLINE_MODELS_PATH}" ]]; then
if [[ ! -d "${OFFLINE_MODELS_PATH}" ]]; then
echo "Warning: OFFLINE_MODELS_PATH='${OFFLINE_MODELS_PATH}' does not exist or is not a directory."
else
mkdir -p "${OLLAMA_HOME}"
if [[ -e "${MODELS_DIR}" ]]; then
rm -rf "${MODELS_DIR}"
fi
ln -s "${OFFLINE_MODELS_PATH}" "${MODELS_DIR}"
echo "Created symlink: ${MODELS_DIR} -> ${OFFLINE_MODELS_PATH}"
fi
fi
echo "Starting Ollama server"
ollama serve &
SERVE_PID=$!
echo "Waiting for Ollama server to be active"
timeout=60
interval=1
elapsed=0
while ! ollama list | grep -q 'NAME'; do
sleep ${interval}
elapsed=$((elapsed + interval))
if [[ ${elapsed} -ge ${timeout} ]]; then
echo "Error: Ollama server did not become active within ${timeout}s." >&2
exit 1
fi
done
echo "Ollama server is active."
wait ${SERVE_PID}