#!/bin/bash #Script : ollama_down.sh #Apps : MRDEVS TOOLS #Description : Detener ollama (IA) en modo local #Author : Mauro Rosero Pérez #Company Email : mauro@rosero.one #Personal Email : mauro.rosero@gmail.com #Created : 2025/03/21 19:27:08 #Modified : 2025/03/21 19:27:08 #Version : 1.3.0 #============================================================================== # Derechos de Autor [2025] [Mauro Rosero P. ] #============================================================================== # Este programa es software libre: usted puede redistribuirlo y/o modificarlo # bajo los términos de la Licencia Pública Affero General de GNU tal como # lo publica la Free Software Foundation, ya sea la versión 3 de la licencia, # o (a su elección) cualquier versión posterior. # # Este programa se distribuye con la esperanza de que sea útil, # pero SIN NINGUNA GARANTÍA; sin siquiera la garantía implícita de # COMERCIABILIDAD o IDONEIDAD PARA UN PROPÓSITO PARTICULAR. Consulte la # Licencia Pública Affero General de GNU para obtener más detalles. # # Debería haber recibido una copia de la Licencia Pública Affero General # junto con este programa. Si no la recibió, consulte . # Configuración inicial # Usar DEVELOPER_DIR de base.lib SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" BIN_BASE="bin" BIN_LIBS="lib" BIN_MESG="msg" BIN_CFGS="config" # Leer DEVSPATH desde el archivo de configuración o usar "devs" por defecto if [ -f "$SCRIPT_DIR/config/devspath.dat" ]; then DEVSPATH=$(cat "$SCRIPT_DIR/$BIN_CFGS/devspath.dat") else DEVSPATH="devs" fi BIN_HOME="$HOME/$DEVSPATH" BIN_PATH=$BIN_HOME/$BIN_BASE VERSION=$(cat "$BIN_HOME/$BIN_BASE/$BIN_CFGS/version") # CHECK SHELL LANGUAGE BIN_LANG=${LANG:0:2} set -e # Importar bibliotecas necesarias source "${BIN_HOME}/${BIN_BASE}/${BIN_LIBS}/base.lib" # Cargar mensajes en el idioma del sistema o español por defecto load_messages "${BIN_HOME}/${BIN_BASE}" "${BIN_MESG}" "${BIN_LANG}" "head" title="${head_000} ${head_002}" # Change to the directory containing the compose file cd "${HOME}/.ollama" # Check if we should use podman or docker (prefer podman) if command -v podman >/dev/null 2>&1; then CONTAINER_CMD="podman" elif command -v docker >/dev/null 2>&1; then CONTAINER_CMD="docker" else echo "Error: Neither podman nor docker is installed" exit 1 fi # Check if compose command exists if command -v ${CONTAINER_CMD}-compose >/dev/null 2>&1; then COMPOSE_CMD="${CONTAINER_CMD}-compose" elif command -v podman-compose >/dev/null 2>&1; then COMPOSE_CMD="podman-compose" elif command -v docker-compose >/dev/null 2>&1; then COMPOSE_CMD="docker-compose" else echo "Error: No compose command found (podman-compose or docker-compose)" exit 1 fi echo "Using ${COMPOSE_CMD} to stop Ollama service..." # Try to stop with compose first ${COMPOSE_CMD} down || echo "Warning: Issue with ${COMPOSE_CMD} down command" # If the container is still running, try to stop it directly if ${CONTAINER_CMD} container exists ollama 2>/dev/null && ${CONTAINER_CMD} ps | grep -q ollama; then echo "Stopping ollama container directly..." ${CONTAINER_CMD} stop ollama fi echo "${head_002} Ollama service stopped successfully"