Add SysVInit Script #7474

Open
opened 2025-11-12 14:07:58 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @Ryushin on GitHub (Jul 6, 2025).

What is the issue?

Not all distributions use SystemD. Please include a SysVInit script, maybe in contrib or something like that. I've included a SysVInit script that works for me under Devuan. Note, I installed Ollama in /opt/ollama and models in /opt/ollama/models. I've included other options as well, including logging to /var/log/ollama/ollama.log

#!/bin/sh
### BEGIN INIT INFO
# Provides:          ollama
# Required-Start:    $network
# Required-Stop:     
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Ollama Service
# Description:       Starts the Ollama Service at boot
### END INIT INFO

. /lib/lsb/init-functions
NAME=ollama
DAEMON=/opt/ollama/bin/ollama
DAEMONUSER=ollama
PIDFILE=/var/run/$NAME.pid
LOGFILE=/var/log/ollama/ollama.log
OLLAMAOPTIONS="OLLAMA_HOST=http://127.0.0.1:11434 OLLAMA_MODELS=/opt/ollama/models OLLAMA_MAX_LOADED_MODELS=1 OLLAMA_KEEP_ALIVE=1800 OLLAMA_MAX_VRAM=5368709120"

case "$1" in
  start)
    log_daemon_msg "Starting Ollama Service"
    start-stop-daemon --start --pidfile $PIDFILE --make-pidfile --background --chuid $DAEMONUSER --startas /bin/bash -- -c "$OLLAMAOPTIONS exec $DAEMON serve >> $LOGFILE 2>&1"
    log_end_msg $?
    ;;
  stop)
    log_daemon_msg "Stopping Ollama Service"
    start-stop-daemon --stop --pidfile $PIDFILE
    log_end_msg $?
    ;;
  restart)
    $0 stop
    $0 start
    ;;
  status)
    status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $?
    ;;
  *)
    echo "Usage: /etc/init.d/$NAME {start|stop|restart|status}"
    exit 1
    ;;
esac

Relevant log output


OS

No response

GPU

No response

CPU

No response

Ollama version

No response

Originally created by @Ryushin on GitHub (Jul 6, 2025). ### What is the issue? Not all distributions use SystemD. Please include a SysVInit script, maybe in contrib or something like that. I've included a SysVInit script that works for me under Devuan. Note, I installed Ollama in /opt/ollama and models in /opt/ollama/models. I've included other options as well, including logging to /var/log/ollama/ollama.log ``` #!/bin/sh ### BEGIN INIT INFO # Provides: ollama # Required-Start: $network # Required-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Ollama Service # Description: Starts the Ollama Service at boot ### END INIT INFO . /lib/lsb/init-functions NAME=ollama DAEMON=/opt/ollama/bin/ollama DAEMONUSER=ollama PIDFILE=/var/run/$NAME.pid LOGFILE=/var/log/ollama/ollama.log OLLAMAOPTIONS="OLLAMA_HOST=http://127.0.0.1:11434 OLLAMA_MODELS=/opt/ollama/models OLLAMA_MAX_LOADED_MODELS=1 OLLAMA_KEEP_ALIVE=1800 OLLAMA_MAX_VRAM=5368709120" case "$1" in start) log_daemon_msg "Starting Ollama Service" start-stop-daemon --start --pidfile $PIDFILE --make-pidfile --background --chuid $DAEMONUSER --startas /bin/bash -- -c "$OLLAMAOPTIONS exec $DAEMON serve >> $LOGFILE 2>&1" log_end_msg $? ;; stop) log_daemon_msg "Stopping Ollama Service" start-stop-daemon --stop --pidfile $PIDFILE log_end_msg $? ;; restart) $0 stop $0 start ;; status) status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $? ;; *) echo "Usage: /etc/init.d/$NAME {start|stop|restart|status}" exit 1 ;; esac ``` ### Relevant log output ```shell ``` ### OS _No response_ ### GPU _No response_ ### CPU _No response_ ### Ollama version _No response_
GiteaMirror added the bug label 2025-11-12 14:07:58 -06:00
Author
Owner

@rick-github commented on GitHub (Jul 6, 2025):

#7336

@rick-github commented on GitHub (Jul 6, 2025): #7336
Author
Owner

@Ryushin commented on GitHub (Jul 6, 2025):

@rick-github should this issue be closed then? Both #7336 and #7732 are both closed. Adding documentation to the manual install and including the init script in scripts or docs would probably go along way. Thoughts?

@Ryushin commented on GitHub (Jul 6, 2025): @rick-github should this issue be closed then? Both #7336 and #7732 are both closed. Adding documentation to the manual install and including the init script in scripts or docs would probably go along way. Thoughts?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama-ollama#7474