git: 8e00cae68c4e - main - misc/ollama: Make ollama service use the 'nobody' user by dfault

From: Yuri Victorovich <yuri_at_FreeBSD.org>
Date: Wed, 24 Jun 2026 06:15:49 UTC
The branch main has been updated by yuri:

URL: https://cgit.FreeBSD.org/ports/commit/?id=8e00cae68c4e8724d7775812a7c4fbf7902cebde

commit 8e00cae68c4e8724d7775812a7c4fbf7902cebde
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2026-06-24 06:11:29 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2026-06-24 06:11:29 +0000

    misc/ollama: Make ollama service use the 'nobody' user by dfault
    
    Suggested by:   Adrian Chadd <adrian@freebsd.org>
---
 misc/ollama/Makefile        |  1 +
 misc/ollama/files/ollama.in | 10 ++++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/misc/ollama/Makefile b/misc/ollama/Makefile
index 90224eaa9c42..fbc7d501336f 100644
--- a/misc/ollama/Makefile
+++ b/misc/ollama/Makefile
@@ -1,6 +1,7 @@
 PORTNAME=	ollama
 DISTVERSIONPREFIX=	v
 DISTVERSION=	0.30.10
+PORTREVISION=	1
 CATEGORIES=	misc # machine-learning
 
 MAINTAINER=	yuri@FreeBSD.org
diff --git a/misc/ollama/files/ollama.in b/misc/ollama/files/ollama.in
index 53c0ee807c29..ae30aa03ffc6 100644
--- a/misc/ollama/files/ollama.in
+++ b/misc/ollama/files/ollama.in
@@ -30,7 +30,7 @@ rcvar=ollama_enable
 load_rc_config $name
 
 : ${ollama_enable:="NO"}
-: ${ollama_user:="root"} # the user nobody doesn't have a home directory and ollama needs one to store the models
+: ${ollama_user:="nobody"}
 : ${ollama_args:="serve"}
 : ${ollama_log:="/var/log/ollama-${ollama_user}.log"}
 : ${ollama_pidfile:="/var/run/${name}-${ollama_user}.pid"}
@@ -50,7 +50,13 @@ ollama_precmd()
 {
     # set environment variables for the ollama server
     export OLLAMA_CONTEXT_LENGTH=${ollama_context_length}
-    export HOME=$(eval echo "~${ollama_user}")
+    if [ "$ollama_user" != "nobody" ]; then
+       export HOME=$(eval echo "~${ollama_user}")
+    else
+       export OLLAMA_MODELS=/var/lib/ollama/models
+       mkdir -p ${OLLAMA_MODELS}
+       chown ${ollama_user} ${OLLAMA_MODELS}
+    fi
     if [ "$ollama_use_vulkan" != "0" ]; then
         export OLLAMA_VULKAN=1
     else