From 0189939f9bcea2cbe55ddc73f7e11384d1d50a1e Mon Sep 17 00:00:00 2001 From: Filipe Fortes Date: Thu, 26 Sep 2024 15:53:04 -0400 Subject: [PATCH] ollama install --- scripts/install_ollama | 34 +++++++++++++++++++ .../.config/systemd/user/ollama.service | 12 +++++++ 2 files changed, 46 insertions(+) create mode 100755 scripts/install_ollama create mode 100644 stowed-files/ollama/.config/systemd/user/ollama.service diff --git a/scripts/install_ollama b/scripts/install_ollama new file mode 100755 index 0000000..164b04b --- /dev/null +++ b/scripts/install_ollama @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# Install Ollama +# +# Usage: install_ollama + +set -euo pipefail +IFS=$'\n\t' +export DEBIAN_FRONTEND=noninteractive + +main() { + local install_location="$HOME/.local/bin/ollama" + local download_dir + download_dir="$(mktemp -d -t ollama-XXXX)" + + if [[ ! -x "${install_location}" ]]; then + echo "Installing Ollama..." + pushd "${download_dir}" > /dev/null + wget --quiet -O "ollama-linux-amd64.tgz" \ + "https://ollama.com/download/ollama-linux-amd64.tgz" + tar -C "$HOME/.local" -xzf "ollama-linux-amd64.tgz" > /dev/null + popd > /dev/null + fi + + echo "Ollama installed, starting service" + systemctl --user start ollama + + # Still need to download models, e.g. `ollama run llama3` + # + # Can also hook up via `llm` by first `llm install llm-ollama` +} + +main + + diff --git a/stowed-files/ollama/.config/systemd/user/ollama.service b/stowed-files/ollama/.config/systemd/user/ollama.service new file mode 100644 index 0000000..885d9f7 --- /dev/null +++ b/stowed-files/ollama/.config/systemd/user/ollama.service @@ -0,0 +1,12 @@ +[Unit] +Description=Ollama Service +After=network-online.target + +[Service] +ExecStart=/home/fortes/.local/bin/ollama serve +Restart=always +RestartSec=3 +Environment="PATH=/home/fortes/.local/bin:${PATH}" + +[Install] +WantedBy=default.target