feat: install Ollama prerequisites during plugin install
This commit is contained in:
Executable
+48
@@ -0,0 +1,48 @@
|
||||
#!/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
|
||||
|
||||
run_privileged() {
|
||||
if [[ "${EUID}" -eq 0 ]]; then
|
||||
"$@"
|
||||
elif command -v sudo >/dev/null 2>&1 && sudo -n true >/dev/null 2>&1; then
|
||||
sudo -n "$@"
|
||||
else
|
||||
printf '%s\n' 'Ollama installation needs root or passwordless sudo.' >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user