#!/usr/bin/env bash # Install Ollama and its Linux prerequisites for Hermes-Ollama_Models. set -Eeuo pipefail if [[ "$(uname -s)" != "Linux" ]]; then printf '%s\n' 'Automatic Ollama installation is currently supported on Linux only.' >&2 exit 1 fi if command -v ollama >/dev/null 2>&1; then ollama --version >/dev/null exit 0 fi if [[ "${EUID}" -ne 0 ]]; then printf '%s\n' 'Ollama installation requires the Hermes container to run as root.' >&2 exit 1 fi run_privileged() { "$@" } if ! command -v curl >/dev/null 2>&1; then if command -v apt-get >/dev/null 2>&1; then run_privileged apt-get update run_privileged apt-get install -y curl ca-certificates elif command -v dnf >/dev/null 2>&1; then run_privileged dnf install -y curl ca-certificates elif command -v yum >/dev/null 2>&1; then run_privileged yum install -y curl ca-certificates elif command -v pacman >/dev/null 2>&1; then run_privileged pacman -Sy --noconfirm curl ca-certificates else printf '%s\n' 'Could not find a supported package manager to install curl and ca-certificates.' >&2 exit 1 fi fi installer="$(mktemp)" trap 'rm -f "$installer"' EXIT curl --fail --silent --show-error --location https://ollama.com/install.sh --output "$installer" run_privileged sh "$installer" command -v ollama >/dev/null 2>&1 ollama --version >/dev/null