[ADDED] Scripts ollama_up.sh y ollama_down.sh para gestionar servicio Ollama (IA local)
- Creados scripts para iniciar y detener el servicio Ollama con podman-compose - Actualizada la configuración para usar la imagen oficial desde docker.io - Implementada compatibilidad con docker y podman - Añadida documentación en README.md 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
2efdcec22e
commit
9bf5f1bf7a
10 changed files with 254 additions and 28 deletions
|
@ -31,7 +31,7 @@
|
||||||
- Use `bin/config/bash.header` how example to bash comment header
|
- Use `bin/config/bash.header` how example to bash comment header
|
||||||
- For new projects created by Claude Code, use author: "Cortana Rosero One <cortana@rosero.one>"
|
- For new projects created by Claude Code, use author: "Cortana Rosero One <cortana@rosero.one>"
|
||||||
- Include reference indicating generation by Claude Code and the version used
|
- Include reference indicating generation by Claude Code and the version used
|
||||||
- Example header comment:
|
- Example header comment for Cortana:
|
||||||
```
|
```
|
||||||
# [Author] Cortana Rosero One <cortana@rosero.one>
|
# [Author] Cortana Rosero One <cortana@rosero.one>
|
||||||
# [Generated] Created by Claude Code (claude-3-7-sonnet-20250219)
|
# [Generated] Created by Claude Code (claude-3-7-sonnet-20250219)
|
||||||
|
|
|
@ -67,6 +67,8 @@ bin/update.sh
|
||||||
| `bin/sora_enable.sh` | Activa el alias 'sora' para Aider permanentemente |
|
| `bin/sora_enable.sh` | Activa el alias 'sora' para Aider permanentemente |
|
||||||
| `bin/sora_disable.sh` | Desactiva el alias 'sora' para Aider |
|
| `bin/sora_disable.sh` | Desactiva el alias 'sora' para Aider |
|
||||||
| `bin/ai_token.sh` | Gestiona tokens de múltiples proveedores de IA vía SOPS |
|
| `bin/ai_token.sh` | Gestiona tokens de múltiples proveedores de IA vía SOPS |
|
||||||
|
| `bin/ollama_up.sh` | Inicia el servicio Ollama (IA local) con podman-compose |
|
||||||
|
| `bin/ollama_down.sh` | Detiene el servicio Ollama (IA local) |
|
||||||
|
|
||||||
### Herramientas para Editores de Código
|
### Herramientas para Editores de Código
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
---
|
---
|
||||||
# Include: includes/load_messages.yaml
|
# Apps: MRDevs Tools
|
||||||
|
# Include: bin/ansible/includes/load_messages.yaml
|
||||||
# Description: load messages languages
|
# Description: load messages languages
|
||||||
# Author: Mauro Rosero P.
|
# Author: Mauro Rosero P.
|
||||||
# Email: mauro@rosero.one (mauro.rosero@gmail.com)
|
# Email: mauro@rosero.one (mauro.rosero@gmail.com)
|
||||||
# Organization: ROSERO ONE
|
# Created: 2025-01-04 12:00:00
|
||||||
# Created: Ene 04, 2025 12:00:00
|
# Modified: 2025-01-05 00:00:00
|
||||||
# Updated: 2025-01-05 00:00:00
|
|
||||||
|
|
||||||
- name: Include language vars messages file
|
- name: Include language vars messages file
|
||||||
ansible.builtin.include_vars:
|
ansible.builtin.include_vars:
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
---
|
---
|
||||||
# Include: includes/sops_credentials.yaml
|
# Apps: MRDevs Tools
|
||||||
|
# Include: bin/ansible/includes/sops_credentials.yaml
|
||||||
# Description: Get sops secure encrypted credentials
|
# Description: Get sops secure encrypted credentials
|
||||||
# Author: Mauro Rosero P.
|
# Author: Mauro Rosero P.
|
||||||
# Email: mauro@rosero.one (mauro.rosero@gmail.com)
|
# Email: mauro@rosero.one (mauro.rosero@gmail.com)
|
||||||
# Organization: ROSERO ONE
|
# Created: 2025-01-04 12:00:00
|
||||||
# Created: Ene 04, 2025 12:00:00
|
# Modified: 2025-01-05 00:00:00
|
||||||
# Updated: 2025-01-05 00:00:00
|
|
||||||
|
|
||||||
- name: Get if credential access exists
|
- name: Get if credential access exists
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
|
|
|
@ -5,16 +5,20 @@
|
||||||
# Global Definitions & Parameters
|
# Global Definitions & Parameters
|
||||||
# Created 2024-03-14-00:12:00
|
# Created 2024-03-14-00:12:00
|
||||||
# Updated 2024-06-01-00:41:00
|
# Updated 2024-06-01-00:41:00
|
||||||
|
|
||||||
console:
|
info: "INFO"
|
||||||
info:
|
warn: "ALERTA"
|
||||||
hello: "{{ info }}Bienvenido, esto es una prueba"
|
fail: "ERROR"
|
||||||
warn:
|
|
||||||
hello: "{{ warn }}Bienvenido, esto es una prueba"
|
console:
|
||||||
error:
|
info:
|
||||||
hello: "{{ fail }}Bienvenido, esto es una prueba"
|
hello: "{{ info }}Bienvenido, esto es una prueba"
|
||||||
no_credentials: "{{ fail }}Archivo de credenciales sops no definido!"
|
warn:
|
||||||
credentials_fail: "{{ fail }}Archivo de credenciales es incorrecto!"
|
hello: "{{ warn }}Bienvenido, esto es una prueba"
|
||||||
no_pritunl_user: "{{ fail }}USUARIO PRITUNL VPN no fue definido!"
|
error:
|
||||||
no_pritunl_email: "{{ fail }}Correo electrónico de USUARIO PRITUNL VPN no fue definido!"
|
hello: "{{ fail }}Bienvenido, esto es una prueba"
|
||||||
no_pritunl_action: "{{ fail }}Acción para gestión de USUARIO PRITUNL VPN es invalida!"
|
no_credentials: "{{ fail }}Archivo de credenciales sops no definido!"
|
||||||
|
credentials_fail: "{{ fail }}Archivo de credenciales es incorrecto!"
|
||||||
|
no_pritunl_user: "{{ fail }}USUARIO PRITUNL VPN no fue definido!"
|
||||||
|
no_pritunl_email: "{{ fail }}Correo electrónico de USUARIO PRITUNL VPN no fue definido!"
|
||||||
|
no_pritunl_action: "{{ fail }}Acción para gestión de USUARIO PRITUNL VPN es invalida!"
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
---
|
---
|
||||||
# Devops Ansible Script
|
# Apps: MRDevs Tools
|
||||||
# Playbook: pritunl_users.yaml
|
# Playbook: bin/ansible/pritunl_users.yaml
|
||||||
# Description: Add, enable, disable or remove pritunl vpn users
|
# Description: Add, enable, disable or remove pritunl vpn users
|
||||||
# Author: Mauro Rosero P.
|
# Author: Mauro Rosero P.
|
||||||
# Email: mauro@rosero.one (mauro.rosero@gmail.com)
|
# Email: mauro@rosero.one (mauro.rosero@gmail.com)
|
||||||
# Organization: ROSERO ONE
|
# Created: 2025-01-04 12:00:00
|
||||||
# Created: Ene 04, 2025 12:00:00
|
# Modified: 2025-01-05 00:00:00
|
||||||
# Updated: 2025-01-05 00:00:00
|
|
||||||
|
|
||||||
|
|
||||||
- name: PLAYBOOK - {{ playbook_program | upper }} ({{ playbook_description | upper }})
|
- name: PLAYBOOK - {{ playbook_program | upper }} ({{ playbook_description | upper }})
|
||||||
hosts: [localhost]
|
hosts: [localhost]
|
||||||
|
|
12
bin/ollama/podman-compose.yml
Normal file
12
bin/ollama/podman-compose.yml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
version: "3.8"
|
||||||
|
|
||||||
|
services:
|
||||||
|
ollama:
|
||||||
|
image: docker.io/ollama/ollama:latest
|
||||||
|
container_name: ollama
|
||||||
|
privileged: true
|
||||||
|
ports:
|
||||||
|
- "11434:11434"
|
||||||
|
volumes:
|
||||||
|
- ../../data:/root/.ollama
|
||||||
|
restart: unless-stopped
|
94
bin/ollama_down.sh
Executable file
94
bin/ollama_down.sh
Executable file
|
@ -0,0 +1,94 @@
|
||||||
|
#!/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.2.0
|
||||||
|
#==============================================================================
|
||||||
|
# Derechos de Autor [2025] [Mauro Rosero P. <mauro@rosero.one>]
|
||||||
|
#==============================================================================
|
||||||
|
# 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 <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# 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 "${BIN_HOME}/${BIN_BASE}/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"
|
115
bin/ollama_up.sh
Executable file
115
bin/ollama_up.sh
Executable file
|
@ -0,0 +1,115 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#Script : ollama_up.sh
|
||||||
|
#Apps : MRDEVS TOOLS
|
||||||
|
#Description : Ejecutar 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.2.0
|
||||||
|
#==============================================================================
|
||||||
|
# Derechos de Autor [2025] [Mauro Rosero P. <mauro@rosero.one>]
|
||||||
|
#==============================================================================
|
||||||
|
# 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 <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# 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 "${BIN_HOME}/${BIN_BASE}/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 start Ollama service..."
|
||||||
|
|
||||||
|
# Fix relative path in volume mount if needed
|
||||||
|
if grep -q "../../data:/root/.ollama" "${BIN_HOME}/${BIN_BASE}/ollama/podman-compose.yml"; then
|
||||||
|
# Create data directory if it doesn't exist
|
||||||
|
mkdir -p "${BIN_HOME}/data"
|
||||||
|
|
||||||
|
# Start Ollama service with compose
|
||||||
|
${COMPOSE_CMD} -f podman-compose.yml up -d
|
||||||
|
else
|
||||||
|
${COMPOSE_CMD} up -d
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Verify container is running
|
||||||
|
if ! ${CONTAINER_CMD} container exists ollama 2>/dev/null || ! ${CONTAINER_CMD} ps | grep -q ollama; then
|
||||||
|
echo "Warning: Container may not be running properly. Trying direct container command..."
|
||||||
|
|
||||||
|
# Try to start it directly if it exists
|
||||||
|
if ${CONTAINER_CMD} container exists ollama 2>/dev/null; then
|
||||||
|
echo "Starting existing ollama container..."
|
||||||
|
${CONTAINER_CMD} start ollama
|
||||||
|
else
|
||||||
|
echo "Creating ollama container directly..."
|
||||||
|
${CONTAINER_CMD} run -d --name ollama \
|
||||||
|
--privileged \
|
||||||
|
-p 11434:11434 \
|
||||||
|
-v "${BIN_HOME}/data:/root/.ollama" \
|
||||||
|
--restart unless-stopped \
|
||||||
|
docker.io/ollama/ollama:latest
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "${head_002} Ollama service started successfully"
|
|
@ -34,6 +34,7 @@ BIN_BASE="bin"
|
||||||
BIN_LIBS="lib"
|
BIN_LIBS="lib"
|
||||||
BIN_MESG="msg"
|
BIN_MESG="msg"
|
||||||
BIN_CFGS="config"
|
BIN_CFGS="config"
|
||||||
|
BIN_ANSIBLE="ansible"
|
||||||
|
|
||||||
# Leer DEVSPATH desde el archivo de configuración o usar "devs" por defecto
|
# Leer DEVSPATH desde el archivo de configuración o usar "devs" por defecto
|
||||||
if [ -f "$SCRIPT_DIR/$BIN_CFGS/devspath.dat" ]; then
|
if [ -f "$SCRIPT_DIR/$BIN_CFGS/devspath.dat" ]; then
|
||||||
|
|
Loading…
Reference in a new issue