#!/bin/bash # setup.sh - Instalacion inicial de NovelasVM set -e REPO_DIR="$(cd "$(dirname "$0")/.." && pwd)" NOVELAS_DIR="/opt/novelas" WWW_DIR="/var/www/novelas" echo "[+] Instalando dependencias..." apt-get update apt-get install -y nginx docker.io docker-compose python3 python3-pip nodejs npm \ xvfb p7zip-full git curl wget imagemagick ufw systemctl enable --now docker usermod -aG docker novelas || true echo "[+] Creando directorios..." mkdir -p "$NOVELAS_DIR"/{bin,builds,projects,tools,config,templates/portal,docs} mkdir -p "$WWW_DIR"/{games,assets} chown -R novelas:novelas "$NOVELAS_DIR" echo "[+] Copiando scripts..." cp "$REPO_DIR/bin/"*.sh "$NOVELAS_DIR/bin/" chmod +x "$NOVELAS_DIR/bin/"*.sh chown -R novelas:novelas "$NOVELAS_DIR/bin" echo "[+] Copiando configuracion..." cp "$REPO_DIR/config/nginx-snippet.template" "$NOVELAS_DIR/config/" echo "[+] Copiando portal..." cp "$REPO_DIR/var-www/index.html" "$WWW_DIR/" cp "$REPO_DIR/var-www/assets/"* "$WWW_DIR/assets/" chown -R www-data:www-data "$WWW_DIR" find "$WWW_DIR" -type f -exec chmod 644 {} \; find "$WWW_DIR" -type d -exec chmod 755 {} \; echo "[+] Configurando nginx..." if [ ! -f /etc/nginx/sites-available/novelas ]; then cat > /etc/nginx/sites-available/novelas <<'NGINX' server { listen 80; server_name _; root /var/www/novelas; index index.html; location / { try_files $uri $uri/ =404; } location /games/umineko/ { return 301 http://192.168.10.111:8081/; } include /etc/nginx/snippets/novelas-games/*.conf; location ~* \.(wasm|data|js|png|jpg|jpeg|gif|ico|svg|opus|ogg|mp3|mp4|webm|zip)$ { expires 30d; add_header Cache-Control "public, immutable"; try_files $uri =404; } location ~* \.wasm$ { add_header Content-Type "application/wasm"; } location ~* ^/(games\.json|games/[^/]+/game\.json)$ { expires -1; add_header Cache-Control "no-store, no-cache, must-revalidate"; try_files $uri =404; } error_log /var/log/nginx/novelas-error.log; access_log /var/log/nginx/novelas-access.log; } NGINX fi ln -sf /etc/nginx/sites-available/novelas /etc/nginx/sites-enabled/novelas rm -f /etc/nginx/sites-enabled/default nginx -t systemctl reload nginx echo "[+] Configurando firewall..." ufw allow 22/tcp ufw allow 80/tcp ufw allow 443/tcp ufw allow 8081/tcp echo "[+] Instalacion completada." echo "Recuerda:" echo " 1. Instalar Ren'Py SDK en $NOVELAS_DIR/tools/renpy" echo " 2. Instalar OnscripterYuri web en $NOVELAS_DIR/tools/onscripter-yuri" echo " 3. Configurar Umineko Web segun docs/UMINEKO.md" echo " 4. Cambiar contrasenas de root y novelas"