diff --git a/hermes/deploy.sh b/hermes/deploy.sh index 6a4fa1a..188f0d8 100755 --- a/hermes/deploy.sh +++ b/hermes/deploy.sh @@ -22,7 +22,7 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" echo "" echo -e "${BOLD}${CYAN}╔══════════════════════════════════════════╗${NC}" echo -e "${BOLD}${CYAN}║ d0a1 pack — Hermes Agent ║${NC}" -echo -e "${BOLD}${CYAN}║ Tu agente de IA. Automatiza todo. ║${NC}" +echo -e "${BOLD}${CYAN}║ Agente de IA desde terminal o Telegram. ║${NC}" echo -e "${BOLD}${CYAN}╚══════════════════════════════════════════╝${NC}" echo "" @@ -54,30 +54,50 @@ if [ "$TOTAL_RAM_GB" -lt 3 ]; then fi echo -e "${GREEN}✓${NC} RAM: ${TOTAL_RAM_GB} GB" -# ── Mode info ─────────────────────────────── +# ── Auto-detect Ollama port ───────────────── +find_free_port() { + local port=$1 + local max_port=$((port + 20)) + while [ "$port" -le "$max_port" ]; do + if ! ss -tlnp 2>/dev/null | grep -q ":${port} " && ! netstat -tlnp 2>/dev/null | grep -q ":${port} "; then + echo "$port" + return 0 + fi + port=$((port + 1)) + done + echo "$1" + return 1 +} + +OLLAMA_PORT=$(find_free_port 11434) + if [ "$MODE" = "vps" ]; then echo -e "${YELLOW}Modo:${NC} VPS" echo "" echo -e " ${BOLD}¿No tienes VPS?${NC} Consigue uno con descuento:" - echo -e " ${CYAN}https://d0a1.es/go/vultr/ — Vultr" - echo -e " ${CYAN}https://d0a1.es/go/digitalocean/ — DigitalOcean ($200 credit)" + echo -e " ${CYAN}https://d0a1.es/go/vultr/${NC} — Vultr" + echo -e " ${CYAN}https://d0a1.es/go/digitalocean/${NC} — DigitalOcean (\$200 credit)" echo "" elif [ "$MODE" != "local" ]; then echo -e "${RED}Modo desconocido: $MODE${NC}" echo "Usa: ./deploy.sh local | vps | stop" exit 1 fi + +if [ "$OLLAMA_PORT" != "11434" ]; then + echo -e "${YELLOW}⚠ Puerto 11434 ocupado, usando ${OLLAMA_PORT}${NC}" +fi echo "" # ── 1. Arrancar Ollama (Docker) ────────────── echo -e "${YELLOW}[1/3]${NC} Arrancando Ollama (IA local)..." if ! docker ps --format '{{.Names}}' | grep -q d0a1-hermes-ollama; then docker run -d --name d0a1-hermes-ollama \ - -p 11434:11434 \ + -p "${OLLAMA_PORT}:11434" \ -v d0a1_hermes_ollama:/root/.ollama \ -e OLLAMA_HOST=0.0.0.0 \ --restart unless-stopped \ - ollama/ollama:0.32.6 + ollama/ollama:0.33.0 fi # Wait for Ollama @@ -94,7 +114,7 @@ until docker exec d0a1-hermes-ollama ollama ps &>/dev/null; do done echo -e "${YELLOW} Descargando modelo (llama3.2:3b, ~2 GB)...${NC}" docker exec d0a1-hermes-ollama ollama pull llama3.2:3b -echo -e "${GREEN}✓${NC} Ollama corriendo en http://localhost:11434" +echo -e "${GREEN}✓${NC} Ollama corriendo en http://localhost:${OLLAMA_PORT}" # ── 2. Instalar Hermes Agent ──────────────── echo -e "${YELLOW}[2/3]${NC} Instalando Hermes Agent..." diff --git a/openclaw/deploy.sh b/openclaw/deploy.sh index 985017b..77f9093 100755 --- a/openclaw/deploy.sh +++ b/openclaw/deploy.sh @@ -22,7 +22,7 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" echo "" echo -e "${BOLD}${CYAN}╔══════════════════════════════════════════╗${NC}" echo -e "${BOLD}${CYAN}║ d0a1 pack — OpenClaw ║${NC}" -echo -e "${BOLD}${CYAN}║ Tu asistente. En tus chats. ║${NC}" +echo -e "${BOLD}${CYAN}║ Asistente de IA en tus chats. ║${NC}" echo -e "${BOLD}${CYAN}╚══════════════════════════════════════════╝${NC}" echo "" @@ -54,30 +54,50 @@ if [ "$TOTAL_RAM_GB" -lt 3 ]; then fi echo -e "${GREEN}✓${NC} RAM: ${TOTAL_RAM_GB} GB" -# ── Mode info ─────────────────────────────── +# ── Auto-detect Ollama port ───────────────── +find_free_port() { + local port=$1 + local max_port=$((port + 20)) + while [ "$port" -le "$max_port" ]; do + if ! ss -tlnp 2>/dev/null | grep -q ":${port} " && ! netstat -tlnp 2>/dev/null | grep -q ":${port} "; then + echo "$port" + return 0 + fi + port=$((port + 1)) + done + echo "$1" + return 1 +} + +OLLAMA_PORT=$(find_free_port 11434) + if [ "$MODE" = "vps" ]; then echo -e "${YELLOW}Modo:${NC} VPS" echo "" echo -e " ${BOLD}¿No tienes VPS?${NC} Consigue uno con descuento:" - echo -e " ${CYAN}https://d0a1.es/go/vultr/ — Vultr" - echo -e " ${CYAN}https://d0a1.es/go/digitalocean/ — DigitalOcean ($200 credit)" + echo -e " ${CYAN}https://d0a1.es/go/vultr/${NC} — Vultr" + echo -e " ${CYAN}https://d0a1.es/go/digitalocean/${NC} — DigitalOcean (\$200 credit)" echo "" elif [ "$MODE" != "local" ]; then echo -e "${RED}Modo desconocido: $MODE${NC}" echo "Usa: ./deploy.sh local | vps | stop" exit 1 fi + +if [ "$OLLAMA_PORT" != "11434" ]; then + echo -e "${YELLOW}⚠ Puerto 11434 ocupado, usando ${OLLAMA_PORT}${NC}" +fi echo "" # ── 1. Arrancar Ollama (Docker) ────────────── echo -e "${YELLOW}[1/3]${NC} Arrancando Ollama (IA local)..." if ! docker ps --format '{{.Names}}' | grep -q d0a1-openclaw-ollama; then docker run -d --name d0a1-openclaw-ollama \ - -p 11434:11434 \ + -p "${OLLAMA_PORT}:11434" \ -v d0a1_openclaw_ollama:/root/.ollama \ -e OLLAMA_HOST=0.0.0.0 \ --restart unless-stopped \ - ollama/ollama:0.32.6 + ollama/ollama:0.33.0 fi # Wait for Ollama @@ -94,7 +114,7 @@ until docker exec d0a1-openclaw-ollama ollama ps &>/dev/null; do done echo -e "${YELLOW} Descargando modelo (llama3.2:3b, ~2 GB)...${NC}" docker exec d0a1-openclaw-ollama ollama pull llama3.2:3b -echo -e "${GREEN}✓${NC} Ollama corriendo en http://localhost:11434" +echo -e "${GREEN}✓${NC} Ollama corriendo en http://localhost:${OLLAMA_PORT}" # ── 2. Instalar OpenClaw ───────────────────── echo -e "${YELLOW}[2/3]${NC} Instalando OpenClaw..." diff --git a/openwebui/deploy.sh b/openwebui/deploy.sh index a072dd4..5e26888 100755 --- a/openwebui/deploy.sh +++ b/openwebui/deploy.sh @@ -23,7 +23,7 @@ COMPOSE_FILE="$SCRIPT_DIR/docker-compose.yml" echo "" echo -e "${BOLD}${CYAN}╔══════════════════════════════════════════╗${NC}" echo -e "${BOLD}${CYAN}║ d0a1 pack — Open WebUI ║${NC}" -echo -e "${BOLD}${CYAN}║ Chat con IA. Privado. Sin cuotas. ║${NC}" +echo -e "${BOLD}${CYAN}║ Chat de IA privado. Sin cuenta, sin API key. ║${NC}" echo -e "${BOLD}${CYAN}╚══════════════════════════════════════════╝${NC}" echo "" @@ -57,22 +57,47 @@ if [ "$TOTAL_RAM_GB" -lt 3 ]; then fi echo -e "${GREEN}✓${NC} RAM: ${TOTAL_RAM_GB} GB" +# ── Auto-detect ports ─────────────────────── +find_free_port() { + local port=$1 + local max_port=$((port + 20)) + while [ "$port" -le "$max_port" ]; do + if ! ss -tlnp 2>/dev/null | grep -q ":${port} " && ! netstat -tlnp 2>/dev/null | grep -q ":${port} "; then + echo "$port" + return 0 + fi + port=$((port + 1)) + done + echo "$1" + return 1 +} + +export OLLAMA_PORT=$(find_free_port 11434) +export WEBUI_PORT=$(find_free_port 3000) + # ── Mode info ─────────────────────────────── if [ "$MODE" = "local" ]; then echo -e "${YELLOW}Modo:${NC} local (tu ordenador)" - echo -e " URL: ${CYAN}http://localhost:3000${NC}" + echo -e " URL: ${CYAN}http://localhost:${WEBUI_PORT}${NC}" elif [ "$MODE" = "vps" ]; then echo -e "${YELLOW}Modo:${NC} VPS (accesible desde fuera)" - echo -e " URL: ${CYAN}http://$(hostname -I 2>/dev/null | awk '{print $1}' || echo 'TU_IP'):3000${NC}" + echo -e " URL: ${CYAN}http://$(hostname -I 2>/dev/null | awk '{print $1}' || echo 'TU_IP'):${WEBUI_PORT}${NC}" echo "" echo -e " ${BOLD}¿No tienes VPS?${NC} Consigue uno con descuento:" - echo -e " ${CYAN}https://d0a1.es/go/vultr/ — Vultr" - echo -e " ${CYAN}https://d0a1.es/go/digitalocean/ — DigitalOcean ($200 credit)" + echo -e " ${CYAN}https://d0a1.es/go/vultr/${NC} — Vultr" + echo -e " ${CYAN}https://d0a1.es/go/digitalocean/${NC} — DigitalOcean (\$200 credit)" else echo -e "${RED}Modo desconocido: $MODE${NC}" echo "Usa: ./deploy.sh local | vps | stop" exit 1 fi + +if [ "$OLLAMA_PORT" != "11434" ]; then + echo -e "${YELLOW}⚠ Puerto 11434 ocupado, usando ${OLLAMA_PORT}${NC}" +fi +if [ "$WEBUI_PORT" != "3000" ]; then + echo -e "${YELLOW}⚠ Puerto 3000 ocupado, usando ${WEBUI_PORT}${NC}" +fi echo "" # ── Deploy ────────────────────────────────── @@ -98,9 +123,9 @@ echo "" echo -e "${BOLD}${GREEN}¡Listo! Tu IA está corriendo.${NC}" echo "" if [ "$MODE" = "local" ]; then - echo -e " ${BOLD}Abre:${NC} ${CYAN}http://localhost:3000${NC}" + echo -e " ${BOLD}Abre:${NC} ${CYAN}http://localhost:${WEBUI_PORT}${NC}" else - echo -e " ${BOLD}Abre:${NC} ${CYAN}http://$(hostname -I 2>/dev/null | awk '{print $1}' || echo 'TU_IP'):3000${NC}" + echo -e " ${BOLD}Abre:${NC} ${CYAN}http://$(hostname -I 2>/dev/null | awk '{print $1}' || echo 'TU_IP'):${WEBUI_PORT}${NC}" fi echo "" echo -e " ${BOLD}Modelos alternativos:${NC}" diff --git a/openwebui/docker-compose.yml b/openwebui/docker-compose.yml index 57b52a2..8f4a255 100644 --- a/openwebui/docker-compose.yml +++ b/openwebui/docker-compose.yml @@ -1,5 +1,5 @@ # d0a1 pack — Open WebUI -# Chat con IA en tu navegador. Como ChatGPT, pero privado. +# Chat de IA privado. Sin cuenta, sin API key. # # Local: ./deploy.sh local → http://localhost:3000 # VPS: ./deploy.sh vps → http://TU_IP:3000 @@ -10,10 +10,10 @@ services: ollama: container_name: d0a1-ollama - image: ollama/ollama:0.32.6 + image: ollama/ollama:0.33.0 restart: unless-stopped ports: - - "11434:11434" + - "${OLLAMA_PORT:-11434}:11434" volumes: - ollama_data:/root/.ollama environment: @@ -29,10 +29,10 @@ services: openwebui: container_name: d0a1-openwebui - image: ghcr.io/open-webui/open-webui:0.11.0 + image: ghcr.io/open-webui/open-webui:0.11.1 restart: unless-stopped ports: - - "3000:8080" + - "${WEBUI_PORT:-3000}:8080" volumes: - openwebui_data:/app/backend/data environment: diff --git a/wordpress/deploy.sh b/wordpress/deploy.sh index 43cd4eb..4f9befc 100755 --- a/wordpress/deploy.sh +++ b/wordpress/deploy.sh @@ -22,8 +22,8 @@ COMPOSE_FILE="$SCRIPT_DIR/docker-compose.yml" echo "" echo -e "${BOLD}${CYAN}╔══════════════════════════════════════════╗${NC}" -echo -e "${BOLD}${CYAN}║ d0a1 pack — WordPress Agéntico ║${NC}" -echo -e "${BOLD}${CYAN}║ WP + IA local. Sin cuotas. ║${NC}" +echo -e "${BOLD}${CYAN}║ d0a1 pack — WordPress + IA ║${NC}" +echo -e "${BOLD}${CYAN}║ WP + IA local. Sin cuotas. ║${NC}" echo -e "${BOLD}${CYAN}╚══════════════════════════════════════════╝${NC}" echo "" @@ -38,6 +38,7 @@ fi # ── Check Docker ──────────────────────────── if ! command -v docker &>/dev/null; then echo -e "${RED}✗ Docker no está instalado.${NC}" + echo "" echo "Instálalo: curl -fsSL https://get.docker.com | sh" exit 1 fi @@ -47,14 +48,6 @@ if ! docker compose version &>/dev/null; then fi echo -e "${GREEN}✓${NC} Docker: $(docker compose version --short 2>/dev/null || echo 'OK')" -# ── Check .env for passwords ────────────────────── -if [ ! -f "$SCRIPT_DIR/.env" ]; then - echo -e "${YELLOW}⚠ No .env file found. Creating from .env.example..." - cp "$SCRIPT_DIR/.env.example" "$SCRIPT_DIR/.env" - echo -e "${YELLOW}⚠ Edit $SCRIPT_DIR/.env to set your own passwords before deploying to production." - echo -e "${CYAN} nano $SCRIPT_DIR/.env"${NC} -fi - # ── Check RAM ─────────────────────────────── TOTAL_RAM_KB=$(grep MemTotal /proc/meminfo 2>/dev/null | awk '{print $2}' || echo "0") TOTAL_RAM_GB=$((TOTAL_RAM_KB / 1024 / 1024)) @@ -64,25 +57,67 @@ if [ "$TOTAL_RAM_GB" -lt 5 ]; then fi echo -e "${GREEN}✓${NC} RAM: ${TOTAL_RAM_GB} GB" +# ── Setup .env ────────────────────────────── +if [ ! -f "$SCRIPT_DIR/.env" ]; then + echo -e "${YELLOW}⚠ No se encontró .env. Creando desde .env.example...${NC}" + cp "$SCRIPT_DIR/.env.example" "$SCRIPT_DIR/.env" + # Generate random passwords for local dev + ROOT_PASS=$(openssl rand -hex 16 2>/dev/null || cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n1) + WP_PASS=$(openssl rand -hex 16 2>/dev/null || cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n1) + sed -i "s/change-me-to-a-strong-password/${ROOT_PASS}/g" "$SCRIPT_DIR/.env" + # Second occurrence is MYSQL_PASSWORD + sed -i "0,/change-me-to-a-strong-password/{s/change-me-to-a-strong-password/${WP_PASS}/}" "$SCRIPT_DIR/.env" + echo -e "${GREEN}✓${NC} Contraseñas generadas en ${SCRIPT_DIR}/.env" +fi + +# ── Auto-detect ports ─────────────────────── +find_free_port() { + local port=$1 + local max_port=$((port + 20)) + while [ "$port" -le "$max_port" ]; do + if ! ss -tlnp 2>/dev/null | grep -q ":${port} " && ! netstat -tlnp 2>/dev/null | grep -q ":${port} "; then + echo "$port" + return 0 + fi + port=$((port + 1)) + done + echo "$1" + return 1 +} + +export OLLAMA_PORT=$(find_free_port 11434) +export WP_PORT=$(find_free_port 8080) +export WEBUI_PORT=$(find_free_port 3000) + # ── Mode info ─────────────────────────────── if [ "$MODE" = "local" ]; then echo -e "${YELLOW}Modo:${NC} local (tu ordenador)" - echo -e " WordPress: ${CYAN}http://localhost:8080${NC}" - echo -e " IA (chat): ${CYAN}http://localhost:3000${NC}" + echo -e " WordPress: ${CYAN}http://localhost:${WP_PORT}${NC}" + echo -e " IA (chat): ${CYAN}http://localhost:${WEBUI_PORT}${NC}" elif [ "$MODE" = "vps" ]; then IP=$(hostname -I 2>/dev/null | awk '{print $1}' || echo 'TU_IP') echo -e "${YELLOW}Modo:${NC} VPS (accesible desde fuera)" - echo -e " WordPress: ${CYAN}http://${IP}:8080${NC}" - echo -e " IA (chat): ${CYAN}http://${IP}:3000${NC}" + echo -e " WordPress: ${CYAN}http://${IP}:${WP_PORT}${NC}" + echo -e " IA (chat): ${CYAN}http://${IP}:${WEBUI_PORT}${NC}" echo "" echo -e " ${BOLD}¿No tienes VPS?${NC} Consigue uno con descuento:" - echo -e " ${CYAN}https://d0a1.es/go/vultr/ — Vultr" - echo -e " ${CYAN}https://d0a1.es/go/digitalocean/ — DigitalOcean ($200 credit)" + echo -e " ${CYAN}https://d0a1.es/go/vultr/${NC} — Vultr" + echo -e " ${CYAN}https://d0a1.es/go/digitalocean/${NC} — DigitalOcean (\$200 credit)" else echo -e "${RED}Modo desconocido: $MODE${NC}" echo "Usa: ./deploy.sh local | vps | stop" exit 1 fi + +if [ "$OLLAMA_PORT" != "11434" ]; then + echo -e "${YELLOW}⚠ Puerto 11434 ocupado, usando ${OLLAMA_PORT}${NC}" +fi +if [ "$WP_PORT" != "8080" ]; then + echo -e "${YELLOW}⚠ Puerto 8080 ocupado, usando ${WP_PORT}${NC}" +fi +if [ "$WEBUI_PORT" != "3000" ]; then + echo -e "${YELLOW}⚠ Puerto 3000 ocupado, usando ${WEBUI_PORT}${NC}" +fi echo "" # ── Deploy ────────────────────────────────── @@ -108,11 +143,11 @@ echo "" echo -e "${BOLD}${GREEN}¡Listo! Tu WordPress con IA está corriendo.${NC}" echo "" if [ "$MODE" = "local" ]; then - echo -e " ${BOLD}WordPress:${NC} ${CYAN}http://localhost:8080${NC}" - echo -e " ${BOLD}IA (chat):${NC} ${CYAN}http://localhost:3000${NC}" + echo -e " ${BOLD}WordPress:${NC} ${CYAN}http://localhost:${WP_PORT}${NC}" + echo -e " ${BOLD}IA (chat):${NC} ${CYAN}http://localhost:${WEBUI_PORT}${NC}" else - echo -e " ${BOLD}WordPress:${NC} ${CYAN}http://${IP}:8080${NC}" - echo -e " ${BOLD}IA (chat):${NC} ${CYAN}http://${IP}:3000${NC}" + echo -e " ${BOLD}WordPress:${NC} ${CYAN}http://${IP}:${WP_PORT}${NC}" + echo -e " ${BOLD}IA (chat):${NC} ${CYAN}http://${IP}:${WEBUI_PORT}${NC}" fi echo "" echo -e " ${BOLD}Configurar WordPress:${NC}" diff --git a/wordpress/docker-compose.yml b/wordpress/docker-compose.yml index 9499375..0fdb7cb 100644 --- a/wordpress/docker-compose.yml +++ b/wordpress/docker-compose.yml @@ -27,10 +27,10 @@ services: wordpress: container_name: d0a1-wp - image: wordpress:7.0-php8.4-apache + image: wordpress:7.1-php8.4-apache restart: unless-stopped ports: - - "8080:80" + - "${WP_PORT:-8080}:80" volumes: - wp_data:/var/www/html environment: @@ -44,10 +44,10 @@ services: ollama: container_name: d0a1-wp-ollama - image: ollama/ollama:0.32.6 + image: ollama/ollama:0.33.0 restart: unless-stopped ports: - - "127.0.0.1:11434:11434" + - "127.0.0.1:${OLLAMA_PORT:-11434}:11434" volumes: - ollama_data:/root/.ollama environment: @@ -62,10 +62,10 @@ services: openwebui: container_name: d0a1-wp-openwebui - image: ghcr.io/open-webui/open-webui:0.11.0 + image: ghcr.io/open-webui/open-webui:0.11.1 restart: unless-stopped ports: - - "3000:8080" + - "${WEBUI_PORT:-3000}:8080" volumes: - openwebui_data:/app/backend/data environment: