feat: support physical and Docker Ollama runtimes

This commit is contained in:
Hermes Agent
2026-08-24 20:22:22 +10:00
parent 9f2be5b368
commit 7def2990ce
5 changed files with 95 additions and 5 deletions
+39
View File
@@ -7,6 +7,45 @@ if [[ "$(uname -s)" != "Linux" ]]; then
exit 1
fi
is_container() {
if [[ -f /.dockerenv ]]; then
return 0
fi
[[ -f /run/.containerenv ]]
}
ollama_endpoint() {
if [[ -n "${OLLAMA_HOST:-}" ]]; then
printf '%s' "${OLLAMA_HOST%/}"
elif is_container; then
printf '%s' 'http://ollama:11434'
else
printf '%s' 'http://localhost:11434'
fi
}
check_endpoint() {
command -v curl >/dev/null 2>&1 || return 1
curl --fail --silent --show-error --max-time 5 "$(ollama_endpoint)/api/version" >/dev/null
}
if [[ "${1:-}" == "--check" ]]; then
if command -v ollama >/dev/null 2>&1 && ! is_container; then
ollama --version >/dev/null
exit 0
fi
check_endpoint
exit $?
fi
if is_container; then
if check_endpoint; then
exit 0
fi
printf '%s\n' 'Docker/container runtime detected. Configure OLLAMA_HOST to a reachable Ollama service (for example http://ollama:11434 or http://host.docker.internal:11434); Hermes will not install Ollama inside its own container.' >&2
exit 1
fi
if command -v ollama >/dev/null 2>&1; then
ollama --version >/dev/null
exit 0