Compare commits

..
Author SHA1 Message Date
hermes d192e3c434 fix: stderr nativo via cmd /c por NativeCommandError en PS 5.1 (issue 4002) 2026-09-12 19:04:00 +02:00
hermes 6c3a594a14 fix: review GATE A — reemplazo de contrasenas sin 3er operando y ANSI 5.1-compat
- wordpress/deploy.ps1: -replace no acepta tercer operando (count) en
  ninguna version de PS; bucle linea a linea (1a = root, 2a = MYSQL_PASSWORD)
- los 4 deploy.ps1: escape ANSI con [char]27 en vez de backtick-e
  (incompatible con Windows PowerShell 5.1); guard solo con NO_COLOR
2026-09-12 18:56:00 +02:00
hermes 0d07146162 feat: deploy.ps1 para Windows en los 4 packs + INSTALL.md con via PowerShell
- deploy.ps1 por pack: equivalente funcional de deploy.sh (docker/compose,
  puertos auto-detect, RAM check, modelo llama3.2:3b, modos local|vps|stop)
- INSTALL.md: instrucciones PowerShell y Bash lado a lado
- WordPress: generacion de contrasenas con RNG nativo (sin openssl),
  root y wp con valores distintos via -replace con limite de 1 coincidencia
2026-09-12 18:41:52 +02:00
4 changed files with 18 additions and 200 deletions

No files matched your search

+4 -47
View File
@@ -65,8 +65,7 @@ if (-not (Get-Command docker -ErrorAction SilentlyContinue)) {
} }
# En PS 5.1, *> $null sobre comandos nativos convierte stderr en errores # En PS 5.1, *> $null sobre comandos nativos convierte stderr en errores
# terminantes con EAP=Stop (PS #4002). Se descarta via cmd /c. # terminantes con EAP=Stop (PS #4002). Se descarta via cmd /c.
$null = cmd /c "docker info >NUL 2>&1" if (-not (cmd /c "docker info >NUL 2>&1")) {
if ($LASTEXITCODE -ne 0) {
Err 'Docker Desktop no responde. Abre Docker Desktop y espera a que arranque.' Err 'Docker Desktop no responde. Abre Docker Desktop y espera a que arranque.'
exit 1 exit 1
} }
@@ -88,7 +87,7 @@ if ($Mode -eq 'vps') {
Write-Host '' Write-Host ''
Write-Host " ${Bold}¿No tienes VPS?${NC} Consigue uno con descuento:" 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/vultr/${NC} - Vultr"
Write-Host " ${Cyan}https://d0a1.es/go/digitalocean/${NC} - DigitalOcean (`$200 credit)" Write-Host " ${Cyan}https://d0a1.es/go/digitalocean/${NC} - DigitalOcean (\$200 credit)"
Write-Host '' Write-Host ''
} }
if ($OllamaPort -ne 11434) { Warn "Puerto 11434 ocupado, usando $OllamaPort" } if ($OllamaPort -ne 11434) { Warn "Puerto 11434 ocupado, usando $OllamaPort" }
@@ -96,7 +95,6 @@ Write-Host ''
# --- 1. Arrancar Ollama (Docker) ------------------------------------------- # --- 1. Arrancar Ollama (Docker) -------------------------------------------
Warn '[1/3] Arrancando Ollama (IA local)...' Warn '[1/3] Arrancando Ollama (IA local)...'
cmd /c docker rm -f d0a1-hermes-ollama '>' NUL '2>&1'
$running = docker ps --format '{{.Names}}' | Select-String -Quiet 'd0a1-hermes-ollama' $running = docker ps --format '{{.Names}}' | Select-String -Quiet 'd0a1-hermes-ollama'
if (-not $running) { if (-not $running) {
docker run -d --name d0a1-hermes-ollama ` docker run -d --name d0a1-hermes-ollama `
@@ -122,49 +120,8 @@ while ($true) {
} }
} }
Warn ' Descargando modelo (llama3.2:3b, ~2 GB)...' Warn ' Descargando modelo (llama3.2:3b, ~2 GB)...'
# Si el usuario define $env:HTTPS_PROXY, Ollama lo usa para el pull (doc oficial): docker exec d0a1-hermes-ollama ollama pull llama3.2:3b
$ProxyEnv = @() if ($LASTEXITCODE -ne 0) { Err 'Fallo la descarga del modelo.'; exit 1 }
if ($env:HTTPS_PROXY) { $ProxyEnv = @('-e', "HTTPS_PROXY=$env:HTTPS_PROXY", '-e', "HTTP_PROXY=$env:HTTP_PROXY") }
$PullOk = $false
foreach ($Attempt in 1..3) {
if ($Attempt -gt 1) { Warn "Reintento $Attempt de 3..." }
docker exec @ProxyEnv d0a1-hermes-ollama ollama pull llama3.2:3b
if ($LASTEXITCODE -eq 0) { $PullOk = $true; break }
Warn 'Descarga interrumpida (red). Reintentando en 5 s...'
Start-Sleep -Seconds 5
}
if (-not $PullOk) {
# --- Fallback: mismo modelo via HuggingFace (otro CDN, no el registry de Ollama) ---
Warn 'Registry de Ollama no accesible. Probando via HuggingFace (mismo modelo)...'
$Gguf = Join-Path $ScriptDir 'llama3.2-3b-q4.gguf'
$Urls = @(
'https://huggingface.co/bartowski/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf',
'https://huggingface.co/unsloth/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf'
)
$DlOk = $false
foreach ($Url in $Urls) {
curl.exe -sL --retry 3 --max-time 1800 -o "$Gguf" $Url
if ($LASTEXITCODE -eq 0 -and (Test-Path $Gguf) -and (Get-Item $Gguf).Length -gt 1900000000) { $DlOk = $true; break }
Warn "Mirror no accesible, probando el siguiente..."
}
if ($DlOk) {
docker cp "$Gguf" d0a1-hermes-ollama:/root/.ollama/import.gguf
docker exec d0a1-hermes-ollama sh -c 'echo FROM /root/.ollama/import.gguf > /tmp/mf && ollama create llama3.2:3b -f /tmp/mf'
$CreateOk = ($LASTEXITCODE -eq 0)
docker exec d0a1-hermes-ollama rm -f /root/.ollama/import.gguf | Out-Null
Remove-Item "$Gguf" -Force -ErrorAction SilentlyContinue
if ($CreateOk) { $PullOk = $true }
else { Err 'Fallo al importar el modelo desde el GGUF.' }
} else {
Err 'No se pudo descargar el modelo (ni registry ni HuggingFace).'
if (-not $env:HTTPS_PROXY) {
Write-Host ' Tu red bloquea ambos. Si tienes proxy/VPN:'
Write-Host ' $env:HTTPS_PROXY = "http://127.0.0.1:7890" # (puerto de tu proxy)'
Write-Host ' .\deploy.ps1 vps'
}
exit 1
}
}
Ok "Ollama corriendo en http://localhost:${OllamaPort}" Ok "Ollama corriendo en http://localhost:${OllamaPort}"
# --- 2. Instalar Hermes Agent ------------------------------------------------ # --- 2. Instalar Hermes Agent ------------------------------------------------
+4 -47
View File
@@ -65,8 +65,7 @@ if (-not (Get-Command docker -ErrorAction SilentlyContinue)) {
} }
# En PS 5.1, *> $null sobre comandos nativos convierte stderr en errores # En PS 5.1, *> $null sobre comandos nativos convierte stderr en errores
# terminantes con EAP=Stop (PS #4002). Se descarta via cmd /c. # terminantes con EAP=Stop (PS #4002). Se descarta via cmd /c.
$null = cmd /c "docker info >NUL 2>&1" if (-not (cmd /c "docker info >NUL 2>&1")) {
if ($LASTEXITCODE -ne 0) {
Err 'Docker Desktop no responde. Abre Docker Desktop y espera a que arranque.' Err 'Docker Desktop no responde. Abre Docker Desktop y espera a que arranque.'
exit 1 exit 1
} }
@@ -88,7 +87,7 @@ if ($Mode -eq 'vps') {
Write-Host '' Write-Host ''
Write-Host " ${Bold}¿No tienes VPS?${NC} Consigue uno con descuento:" 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/vultr/${NC} - Vultr"
Write-Host " ${Cyan}https://d0a1.es/go/digitalocean/${NC} - DigitalOcean (`$200 credit)" Write-Host " ${Cyan}https://d0a1.es/go/digitalocean/${NC} - DigitalOcean (\$200 credit)"
Write-Host '' Write-Host ''
} }
if ($OllamaPort -ne 11434) { Warn "Puerto 11434 ocupado, usando $OllamaPort" } if ($OllamaPort -ne 11434) { Warn "Puerto 11434 ocupado, usando $OllamaPort" }
@@ -96,7 +95,6 @@ Write-Host ''
# --- 1. Arrancar Ollama (Docker) ------------------------------------------- # --- 1. Arrancar Ollama (Docker) -------------------------------------------
Warn '[1/3] Arrancando Ollama (IA local)...' Warn '[1/3] Arrancando Ollama (IA local)...'
cmd /c docker rm -f d0a1-openclaw-ollama '>' NUL '2>&1'
$running = docker ps --format '{{.Names}}' | Select-String -Quiet 'd0a1-openclaw-ollama' $running = docker ps --format '{{.Names}}' | Select-String -Quiet 'd0a1-openclaw-ollama'
if (-not $running) { if (-not $running) {
docker run -d --name d0a1-openclaw-ollama ` docker run -d --name d0a1-openclaw-ollama `
@@ -122,49 +120,8 @@ while ($true) {
} }
} }
Warn ' Descargando modelo (llama3.2:3b, ~2 GB)...' Warn ' Descargando modelo (llama3.2:3b, ~2 GB)...'
# Si el usuario define $env:HTTPS_PROXY, Ollama lo usa para el pull (doc oficial): docker exec d0a1-openclaw-ollama ollama pull llama3.2:3b
$ProxyEnv = @() if ($LASTEXITCODE -ne 0) { Err 'Fallo la descarga del modelo.'; exit 1 }
if ($env:HTTPS_PROXY) { $ProxyEnv = @('-e', "HTTPS_PROXY=$env:HTTPS_PROXY", '-e', "HTTP_PROXY=$env:HTTP_PROXY") }
$PullOk = $false
foreach ($Attempt in 1..3) {
if ($Attempt -gt 1) { Warn "Reintento $Attempt de 3..." }
docker exec @ProxyEnv d0a1-openclaw-ollama ollama pull llama3.2:3b
if ($LASTEXITCODE -eq 0) { $PullOk = $true; break }
Warn 'Descarga interrumpida (red). Reintentando en 5 s...'
Start-Sleep -Seconds 5
}
if (-not $PullOk) {
# --- Fallback: mismo modelo via HuggingFace (otro CDN, no el registry de Ollama) ---
Warn 'Registry de Ollama no accesible. Probando via HuggingFace (mismo modelo)...'
$Gguf = Join-Path $ScriptDir 'llama3.2-3b-q4.gguf'
$Urls = @(
'https://huggingface.co/bartowski/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf',
'https://huggingface.co/unsloth/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf'
)
$DlOk = $false
foreach ($Url in $Urls) {
curl.exe -sL --retry 3 --max-time 1800 -o "$Gguf" $Url
if ($LASTEXITCODE -eq 0 -and (Test-Path $Gguf) -and (Get-Item $Gguf).Length -gt 1900000000) { $DlOk = $true; break }
Warn "Mirror no accesible, probando el siguiente..."
}
if ($DlOk) {
docker cp "$Gguf" d0a1-openclaw-ollama:/root/.ollama/import.gguf
docker exec d0a1-openclaw-ollama sh -c 'echo FROM /root/.ollama/import.gguf > /tmp/mf && ollama create llama3.2:3b -f /tmp/mf'
$CreateOk = ($LASTEXITCODE -eq 0)
docker exec d0a1-openclaw-ollama rm -f /root/.ollama/import.gguf | Out-Null
Remove-Item "$Gguf" -Force -ErrorAction SilentlyContinue
if ($CreateOk) { $PullOk = $true }
else { Err 'Fallo al importar el modelo desde el GGUF.' }
} else {
Err 'No se pudo descargar el modelo (ni registry ni HuggingFace).'
if (-not $env:HTTPS_PROXY) {
Write-Host ' Tu red bloquea ambos. Si tienes proxy/VPN:'
Write-Host ' $env:HTTPS_PROXY = "http://127.0.0.1:7890" # (puerto de tu proxy)'
Write-Host ' .\deploy.ps1 vps'
}
exit 1
}
}
Ok "Ollama corriendo en http://localhost:${OllamaPort}" Ok "Ollama corriendo en http://localhost:${OllamaPort}"
# --- 2. Instalar OpenClaw ----------------------------------------------------- # --- 2. Instalar OpenClaw -----------------------------------------------------
+5 -54
View File
@@ -63,8 +63,7 @@ if (-not (Get-Command docker -ErrorAction SilentlyContinue)) {
} }
# En PS 5.1, *> $null sobre comandos nativos convierte stderr en errores # En PS 5.1, *> $null sobre comandos nativos convierte stderr en errores
# terminantes con EAP=Stop (PS #4002). Se descarta via cmd /c. # terminantes con EAP=Stop (PS #4002). Se descarta via cmd /c.
$null = cmd /c "docker info >NUL 2>&1" if (-not (cmd /c "docker info >NUL 2>&1")) {
if ($LASTEXITCODE -ne 0) {
Err 'Docker Desktop no responde. Abre Docker Desktop y espera a que arranque.' Err 'Docker Desktop no responde. Abre Docker Desktop y espera a que arranque.'
exit 1 exit 1
} }
@@ -96,19 +95,15 @@ if ($Mode -eq 'local') {
Write-Host " URL: ${Cyan}http://localhost:${WebUiPort}${NC}" Write-Host " URL: ${Cyan}http://localhost:${WebUiPort}${NC}"
} else { } else {
Warn 'Modo: VPS (accesible desde fuera)' Warn 'Modo: VPS (accesible desde fuera)'
# IP real de LAN: la de la interfaz con la ruta por defecto (evita vEthernet
# WSL/Hyper-V, Docker, VPN — que son 172.16-31.*, 10.x internos, etc.)
$GwIf = (Get-NetRoute -DestinationPrefix '0.0.0.0/0' -ErrorAction SilentlyContinue |
Sort-Object RouteMetric | Select-Object -First 1).ifIndex
$Ip = (Get-NetIPAddress -AddressFamily IPv4 -ErrorAction SilentlyContinue | $Ip = (Get-NetIPAddress -AddressFamily IPv4 -ErrorAction SilentlyContinue |
Where-Object { $_.ifIndex -eq $GwIf -and $_.IPAddress -notlike '127.*' } | Where-Object { $_.IPAddress -notlike '127.*' -and $_.IPAddress -notlike '169.254.*' } |
Select-Object -First 1).IPAddress Select-Object -First 1).IPAddress
if (-not $Ip) { $Ip = 'TU_IP' } if (-not $Ip) { $Ip = 'TU_IP' }
Write-Host " URL: ${Cyan}http://${Ip}:${WebUiPort}${NC}" Write-Host " URL: ${Cyan}http://${Ip}:${WebUiPort}${NC}"
Write-Host '' Write-Host ''
Write-Host " ${Bold}¿No tienes VPS?${NC} Consigue uno con descuento:" 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/vultr/${NC} - Vultr"
Write-Host " ${Cyan}https://d0a1.es/go/digitalocean/${NC} - DigitalOcean (`$200 credit)" Write-Host " ${Cyan}https://d0a1.es/go/digitalocean/${NC} - DigitalOcean (\$200 credit)"
} }
if ($OllamaPort -ne 11434) { Warn "Puerto 11434 ocupado, usando $OllamaPort" } if ($OllamaPort -ne 11434) { Warn "Puerto 11434 ocupado, usando $OllamaPort" }
@@ -116,9 +111,6 @@ if ($WebUiPort -ne 3000) { Warn "Puerto 3000 ocupado, usando $WebUiPort" }
Write-Host '' Write-Host ''
# --- Deploy ---------------------------------------------------------------- # --- Deploy ----------------------------------------------------------------
# Si hay un deploy previo del pack, tumbarlo primero (mantiene los volumenes:
# el modelo ya descargado no se re-descarga) para que los nuevos puertos apliquen.
cmd /c docker compose -f $ComposeFile down '>' NUL '2>&1'
Warn 'Descargando contenedores (2-3 min la primera vez)...' Warn 'Descargando contenedores (2-3 min la primera vez)...'
$env:OLLAMA_PORT = "$OllamaPort" $env:OLLAMA_PORT = "$OllamaPort"
$env:WEBUI_PORT = "$WebUiPort" $env:WEBUI_PORT = "$WebUiPort"
@@ -139,49 +131,8 @@ while ($true) {
exit 1 exit 1
} }
} }
# Si el usuario define $env:HTTPS_PROXY, Ollama lo usa para el pull (doc oficial): docker exec d0a1-ollama ollama pull llama3.2:3b
$ProxyEnv = @() if ($LASTEXITCODE -ne 0) { Err 'Fallo la descarga del modelo.'; exit 1 }
if ($env:HTTPS_PROXY) { $ProxyEnv = @('-e', "HTTPS_PROXY=$env:HTTPS_PROXY", '-e', "HTTP_PROXY=$env:HTTP_PROXY") }
$PullOk = $false
foreach ($Attempt in 1..3) {
if ($Attempt -gt 1) { Warn "Reintento $Attempt de 3..." }
docker exec @ProxyEnv d0a1-ollama ollama pull llama3.2:3b
if ($LASTEXITCODE -eq 0) { $PullOk = $true; break }
Warn 'Descarga interrumpida (red). Reintentando en 5 s...'
Start-Sleep -Seconds 5
}
if (-not $PullOk) {
# --- Fallback: mismo modelo via HuggingFace (otro CDN, no el registry de Ollama) ---
Warn 'Registry de Ollama no accesible. Probando via HuggingFace (mismo modelo)...'
$Gguf = Join-Path $ScriptDir 'llama3.2-3b-q4.gguf'
$Urls = @(
'https://huggingface.co/bartowski/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf',
'https://huggingface.co/unsloth/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf'
)
$DlOk = $false
foreach ($Url in $Urls) {
curl.exe -sL --retry 3 --max-time 1800 -o "$Gguf" $Url
if ($LASTEXITCODE -eq 0 -and (Test-Path $Gguf) -and (Get-Item $Gguf).Length -gt 1900000000) { $DlOk = $true; break }
Warn "Mirror no accesible, probando el siguiente..."
}
if ($DlOk) {
docker cp "$Gguf" d0a1-ollama:/root/.ollama/import.gguf
docker exec d0a1-ollama sh -c 'echo FROM /root/.ollama/import.gguf > /tmp/mf && ollama create llama3.2:3b -f /tmp/mf'
$CreateOk = ($LASTEXITCODE -eq 0)
docker exec d0a1-ollama rm -f /root/.ollama/import.gguf | Out-Null
Remove-Item "$Gguf" -Force -ErrorAction SilentlyContinue
if ($CreateOk) { $PullOk = $true }
else { Err 'Fallo al importar el modelo desde el GGUF.' }
} else {
Err 'No se pudo descargar el modelo (ni registry ni HuggingFace).'
if (-not $env:HTTPS_PROXY) {
Write-Host ' Tu red bloquea ambos. Si tienes proxy/VPN:'
Write-Host ' $env:HTTPS_PROXY = "http://127.0.0.1:7890" # (puerto de tu proxy)'
Write-Host ' .\deploy.ps1 vps'
}
exit 1
}
}
# --- Done ------------------------------------------------------------------- # --- Done -------------------------------------------------------------------
Write-Host '' Write-Host ''
+5 -52
View File
@@ -63,8 +63,7 @@ if (-not (Get-Command docker -ErrorAction SilentlyContinue)) {
} }
# En PS 5.1, *> $null sobre comandos nativos convierte stderr en errores # En PS 5.1, *> $null sobre comandos nativos convierte stderr en errores
# terminantes con EAP=Stop (PS #4002). Se descarta via cmd /c. # terminantes con EAP=Stop (PS #4002). Se descarta via cmd /c.
$null = cmd /c "docker info >NUL 2>&1" if (-not (cmd /c "docker info >NUL 2>&1")) {
if ($LASTEXITCODE -ne 0) {
Err 'Docker Desktop no responde. Abre Docker Desktop y espera a que arranque.' Err 'Docker Desktop no responde. Abre Docker Desktop y espera a que arranque.'
exit 1 exit 1
} }
@@ -131,12 +130,8 @@ if ($Mode -eq 'local') {
Write-Host " IA (chat): ${Cyan}http://localhost:${WebUiPort}${NC}" Write-Host " IA (chat): ${Cyan}http://localhost:${WebUiPort}${NC}"
} else { } else {
Warn 'Modo: VPS (accesible desde fuera)' Warn 'Modo: VPS (accesible desde fuera)'
# IP real de LAN: la de la interfaz con la ruta por defecto (evita
# vEthernet WSL/Hyper-V, Docker, VPN)
$GwIf = (Get-NetRoute -DestinationPrefix '0.0.0.0/0' -ErrorAction SilentlyContinue |
Sort-Object RouteMetric | Select-Object -First 1).ifIndex
$Ip = (Get-NetIPAddress -AddressFamily IPv4 -ErrorAction SilentlyContinue | $Ip = (Get-NetIPAddress -AddressFamily IPv4 -ErrorAction SilentlyContinue |
Where-Object { $_.ifIndex -eq $GwIf -and $_.IPAddress -notlike '127.*' } | Where-Object { $_.IPAddress -notlike '127.*' -and $_.IPAddress -notlike '169.254.*' } |
Select-Object -First 1).IPAddress Select-Object -First 1).IPAddress
if (-not $Ip) { $Ip = 'TU_IP' } if (-not $Ip) { $Ip = 'TU_IP' }
Write-Host " WordPress: ${Cyan}http://${Ip}:${WpPort}${NC}" Write-Host " WordPress: ${Cyan}http://${Ip}:${WpPort}${NC}"
@@ -144,7 +139,7 @@ if ($Mode -eq 'local') {
Write-Host '' Write-Host ''
Write-Host " ${Bold}¿No tienes VPS?${NC} Consigue uno con descuento:" 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/vultr/${NC} - Vultr"
Write-Host " ${Cyan}https://d0a1.es/go/digitalocean/${NC} - DigitalOcean (`$200 credit)" Write-Host " ${Cyan}https://d0a1.es/go/digitalocean/${NC} - DigitalOcean (\$200 credit)"
} }
if ($OllamaPort -ne 11434) { Warn "Puerto 11434 ocupado, usando $OllamaPort" } if ($OllamaPort -ne 11434) { Warn "Puerto 11434 ocupado, usando $OllamaPort" }
@@ -154,7 +149,6 @@ Write-Host ''
# --- Deploy ---------------------------------------------------------------- # --- Deploy ----------------------------------------------------------------
Warn 'Descargando contenedores (3-5 min la primera vez)...' Warn 'Descargando contenedores (3-5 min la primera vez)...'
cmd /c docker compose -f $ComposeFile down '>' NUL '2>&1'
$env:OLLAMA_PORT = "$OllamaPort" $env:OLLAMA_PORT = "$OllamaPort"
$env:WP_PORT = "$WpPort" $env:WP_PORT = "$WpPort"
$env:WEBUI_PORT = "$WebUiPort" $env:WEBUI_PORT = "$WebUiPort"
@@ -175,49 +169,8 @@ while ($true) {
exit 1 exit 1
} }
} }
# Si el usuario define $env:HTTPS_PROXY, Ollama lo usa para el pull (doc oficial): docker exec d0a1-wp-ollama ollama pull llama3.2:3b
$ProxyEnv = @() if ($LASTEXITCODE -ne 0) { Err 'Fallo la descarga del modelo.'; exit 1 }
if ($env:HTTPS_PROXY) { $ProxyEnv = @('-e', "HTTPS_PROXY=$env:HTTPS_PROXY", '-e', "HTTP_PROXY=$env:HTTP_PROXY") }
$PullOk = $false
foreach ($Attempt in 1..3) {
if ($Attempt -gt 1) { Warn "Reintento $Attempt de 3..." }
docker exec @ProxyEnv d0a1-wp-ollama ollama pull llama3.2:3b
if ($LASTEXITCODE -eq 0) { $PullOk = $true; break }
Warn 'Descarga interrumpida (red). Reintentando en 5 s...'
Start-Sleep -Seconds 5
}
if (-not $PullOk) {
# --- Fallback: mismo modelo via HuggingFace (otro CDN, no el registry de Ollama) ---
Warn 'Registry de Ollama no accesible. Probando via HuggingFace (mismo modelo)...'
$Gguf = Join-Path $ScriptDir 'llama3.2-3b-q4.gguf'
$Urls = @(
'https://huggingface.co/bartowski/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf',
'https://huggingface.co/unsloth/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf'
)
$DlOk = $false
foreach ($Url in $Urls) {
curl.exe -sL --retry 3 --max-time 1800 -o "$Gguf" $Url
if ($LASTEXITCODE -eq 0 -and (Test-Path $Gguf) -and (Get-Item $Gguf).Length -gt 1900000000) { $DlOk = $true; break }
Warn "Mirror no accesible, probando el siguiente..."
}
if ($DlOk) {
docker cp "$Gguf" d0a1-wp-ollama:/root/.ollama/import.gguf
docker exec d0a1-wp-ollama sh -c 'echo FROM /root/.ollama/import.gguf > /tmp/mf && ollama create llama3.2:3b -f /tmp/mf'
$CreateOk = ($LASTEXITCODE -eq 0)
docker exec d0a1-wp-ollama rm -f /root/.ollama/import.gguf | Out-Null
Remove-Item "$Gguf" -Force -ErrorAction SilentlyContinue
if ($CreateOk) { $PullOk = $true }
else { Err 'Fallo al importar el modelo desde el GGUF.' }
} else {
Err 'No se pudo descargar el modelo (ni registry ni HuggingFace).'
if (-not $env:HTTPS_PROXY) {
Write-Host ' Tu red bloquea ambos. Si tienes proxy/VPN:'
Write-Host ' $env:HTTPS_PROXY = "http://127.0.0.1:7890" # (puerto de tu proxy)'
Write-Host ' .\deploy.ps1 vps'
}
exit 1
}
}
# --- Done ------------------------------------------------------------------- # --- Done -------------------------------------------------------------------
Write-Host '' Write-Host ''