feat: deploy.ps1 para Windows en los 4 packs + INSTALL.md (#1)
Co-authored-by: Hermes Agent <hermes@d0a1.es>
This commit was merged in pull request #1.
This commit is contained in:
1 parent
e6f047e45f
commit
23631884dd
5 files changed
+744
-1
No files matched your search
@@ -0,0 +1,161 @@
|
||||
# d0a1 pack - Hermes Agent (Windows)
|
||||
# Agente de IA desde terminal o Telegram.
|
||||
#
|
||||
# Local: .\deploy.ps1 local -> terminal + http://localhost:11434 (Ollama)
|
||||
# VPS: .\deploy.ps1 vps -> + gateway accesible desde fuera
|
||||
# Stop: .\deploy.ps1 stop -> para Ollama
|
||||
#
|
||||
# Requiere: Docker Desktop para Windows (https://docs.docker.com/desktop/)
|
||||
|
||||
param(
|
||||
[Parameter(Position = 0)]
|
||||
[ValidateSet('local', 'vps', 'stop')]
|
||||
[string]$Mode = 'local'
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
# Escape ANSI via [char]27 (compatible con Windows PowerShell 5.1 y PS 7+)
|
||||
$Esc = [char]27
|
||||
$Green = "$Esc[32m"; $Cyan = "$Esc[36m"; $Yellow = "$Esc[33m"; $Red = "$Esc[31m"; $Bold = "$Esc[1m"; $NC = "$Esc[0m"
|
||||
if ($env:NO_COLOR) {
|
||||
$Green = $Cyan = $Yellow = $Red = $Bold = $NC = ''
|
||||
}
|
||||
|
||||
function Info($msg) { Write-Host "${Bold}${Green}>>>${NC} $msg" }
|
||||
function Warn($msg) { Write-Host "${Bold}${Yellow}>>>${NC} $msg" }
|
||||
function Err($msg) { Write-Host "${Bold}${Red}>>>${NC} $msg" }
|
||||
function Ok($msg) { Write-Host "${Green}OK${NC} $msg" }
|
||||
|
||||
function Find-FreePort([int]$Start) {
|
||||
for ($p = $Start; $p -le ($Start + 20); $p++) {
|
||||
$inUse = Get-NetTCPConnection -LocalPort $p -State Listen -ErrorAction SilentlyContinue
|
||||
if (-not $inUse) { return $p }
|
||||
}
|
||||
return $Start
|
||||
}
|
||||
|
||||
Write-Host ''
|
||||
Write-Host "${Bold}${Cyan}============================================================${NC}"
|
||||
Write-Host "${Bold}${Cyan} d0a1 pack - Hermes Agent (Windows)${NC}"
|
||||
Write-Host "${Bold}${Cyan} Agente de IA desde terminal o Telegram.${NC}"
|
||||
Write-Host "${Bold}${Cyan}============================================================${NC}"
|
||||
Write-Host ''
|
||||
|
||||
# --- Stop mode ------------------------------------------------------------
|
||||
if ($Mode -eq 'stop') {
|
||||
$running = docker ps --format '{{.Names}}' | Select-String -Quiet 'd0a1-hermes-ollama'
|
||||
if ($running) {
|
||||
docker stop d0a1-hermes-ollama | Out-Null
|
||||
docker rm d0a1-hermes-ollama | Out-Null
|
||||
Info 'Ollama parado.'
|
||||
} else {
|
||||
Write-Host 'Ollama no esta corriendo.'
|
||||
}
|
||||
exit 0
|
||||
}
|
||||
|
||||
# --- Check Docker (para Ollama) -------------------------------------------
|
||||
if (-not (Get-Command docker -ErrorAction SilentlyContinue)) {
|
||||
Err 'Docker no esta instalado (necesario para Ollama).'
|
||||
Write-Host ''
|
||||
Write-Host 'Instala Docker Desktop para Windows:'
|
||||
Write-Host ' https://docs.docker.com/desktop/setup/install/windows-install/'
|
||||
exit 1
|
||||
}
|
||||
# En PS 5.1, *> $null sobre comandos nativos convierte stderr en errores
|
||||
# terminantes con EAP=Stop (PS #4002). Se descarta via cmd /c.
|
||||
if (-not (cmd /c "docker info >NUL 2>&1")) {
|
||||
Err 'Docker Desktop no responde. Abre Docker Desktop y espera a que arranque.'
|
||||
exit 1
|
||||
}
|
||||
Ok "Docker: $((docker --version) -replace 'Docker version ','' -replace ',.*','')"
|
||||
|
||||
# --- Check RAM ------------------------------------------------------------
|
||||
$TotalRamGb = [math]::Round((Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory / 1GB, 1)
|
||||
if ($TotalRamGb -lt 3.5) {
|
||||
Err "Se necesitan 4 GB de RAM minimo (detectado: $TotalRamGb GB)."
|
||||
exit 1
|
||||
}
|
||||
Ok "RAM: $TotalRamGb GB"
|
||||
|
||||
# --- Auto-detect Ollama port ------------------------------------------------
|
||||
$OllamaPort = Find-FreePort 11434
|
||||
|
||||
if ($Mode -eq 'vps') {
|
||||
Warn 'Modo: VPS'
|
||||
Write-Host ''
|
||||
Write-Host " ${Bold}¿No tienes VPS?${NC} Consigue uno con descuento:"
|
||||
Write-Host " ${Cyan}https://d0a1.es/go/vultr/${NC} - Vultr"
|
||||
Write-Host " ${Cyan}https://d0a1.es/go/digitalocean/${NC} - DigitalOcean (\$200 credit)"
|
||||
Write-Host ''
|
||||
}
|
||||
if ($OllamaPort -ne 11434) { Warn "Puerto 11434 ocupado, usando $OllamaPort" }
|
||||
Write-Host ''
|
||||
|
||||
# --- 1. Arrancar Ollama (Docker) -------------------------------------------
|
||||
Warn '[1/3] Arrancando Ollama (IA local)...'
|
||||
$running = docker ps --format '{{.Names}}' | Select-String -Quiet 'd0a1-hermes-ollama'
|
||||
if (-not $running) {
|
||||
docker run -d --name d0a1-hermes-ollama `
|
||||
-p "${OllamaPort}:11434" `
|
||||
-v d0a1_hermes_ollama:/root/.ollama `
|
||||
-e OLLAMA_HOST=0.0.0.0 `
|
||||
--restart unless-stopped `
|
||||
ollama/ollama:0.33.3 | Out-Null
|
||||
if ($LASTEXITCODE -ne 0) { Err 'Fallo al arrancar el contenedor de Ollama.'; exit 1 }
|
||||
}
|
||||
|
||||
Warn ' Esperando a que Ollama arranque...'
|
||||
$MaxWait = 60; $Waited = 0
|
||||
while ($true) {
|
||||
# Descarte de stderr via cmd /c (ver nota de PS 5.1 / PS #4002 arriba)
|
||||
cmd /c "docker exec d0a1-hermes-ollama ollama ps >NUL 2>&1"
|
||||
if ($LASTEXITCODE -eq 0) { break }
|
||||
Start-Sleep -Seconds 2
|
||||
$Waited += 2
|
||||
if ($Waited -ge $MaxWait) {
|
||||
Err 'Ollama no arranco. Revisa: docker logs d0a1-hermes-ollama'
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
Warn ' Descargando modelo (llama3.2:3b, ~2 GB)...'
|
||||
docker exec d0a1-hermes-ollama ollama pull llama3.2:3b
|
||||
if ($LASTEXITCODE -ne 0) { Err 'Fallo la descarga del modelo.'; exit 1 }
|
||||
Ok "Ollama corriendo en http://localhost:${OllamaPort}"
|
||||
|
||||
# --- 2. Instalar Hermes Agent ------------------------------------------------
|
||||
Warn '[2/3] Instalando Hermes Agent...'
|
||||
if (Get-Command hermes -ErrorAction SilentlyContinue) {
|
||||
Ok "Hermes Agent ya instalado: $(cmd /c 'hermes --version 2>NUL')"
|
||||
} else {
|
||||
# En Windows: instala con winget o pip. El install.sh de Linux no aplica.
|
||||
Write-Host ' Instalando con pip (requiere Python 3.10+)...'
|
||||
pip install --user hermes-agent
|
||||
if ($LASTEXITCODE -ne 0 -or -not (Get-Command hermes -ErrorAction SilentlyContinue)) {
|
||||
Err 'Hermes Agent no se instalo. Instalalo manualmente:'
|
||||
Write-Host ' https://hermes-agent.nousresearch.com/docs'
|
||||
exit 1
|
||||
}
|
||||
Ok "Hermes Agent instalado: $(cmd /c 'hermes --version 2>NUL')"
|
||||
}
|
||||
|
||||
# --- 3. Configurar ------------------------------------------------------------
|
||||
Warn '[3/3] Configurando...'
|
||||
Write-Host ''
|
||||
Write-Host " ${Bold}Ejecuta estos comandos para terminar:${NC}"
|
||||
Write-Host ''
|
||||
Write-Host " ${Cyan}hermes setup${NC} - configuracion interactiva"
|
||||
Write-Host " ${Cyan}hermes model${NC} - elige modelo (Ollama ya esta corriendo)"
|
||||
Write-Host " ${Cyan}hermes gateway setup${NC} - conecta mensajeria (Telegram, etc.)"
|
||||
Write-Host ''
|
||||
|
||||
if ($Mode -eq 'vps') {
|
||||
Write-Host " ${Bold}Para VPS:${NC} configura el gateway para acceso remoto:"
|
||||
Write-Host " ${Cyan}hermes gateway setup --portal${NC}"
|
||||
Write-Host ''
|
||||
}
|
||||
|
||||
Write-Host " ${Bold}Parar:${NC} .\deploy.ps1 stop"
|
||||
Write-Host " ${Bold}¿Quieres mas?${NC} ${Cyan}https://d0a1.es/packs/${NC}"
|
||||
Write-Host ''
|
||||
Reference in new issue
Block a user