#!/bin/bash # # StreamingPro - Instalador Unificado v2.0 # Copyright (c) 2024 StreamingPro # # Uso: curl -fsSL https://install.streamingpro.es | sudo bash # # ARQUITECTURA v2.0: # - Proxy central (Traefik) para multiples apps # - SSL automatico con Let's Encrypt # - Cada app usa su propio dominio # # NO usar set -e - causa problemas con scripts interactivos y subprocesos # ============================================================================= # CONFIGURACION BASE # ============================================================================= VERSION="2.0.0" BASE_URL="https://install.streamingpro.es" # Directorios de instalacion PROXY_DIR="/opt/streamingpro-proxy" CENTRAL_DIR="/opt/streamingpro-central" INTERCOM_DIR="/opt/streamingpro-intercom" # Colores RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' CYAN='\033[0;36m' WHITE='\033[1;37m' NC='\033[0m' # Idioma por defecto LANG_CODE="es" # ============================================================================= # SISTEMA DE TRADUCCIONES (i18n) # ============================================================================= t() { local key="$1" local var_name="MSG_${LANG_CODE}_${key}" echo "${!var_name}" } # --- ESPAÑOL --- MSG_es_WELCOME="Bienvenido al instalador de StreamingPro" MSG_es_SELECT_LANG="Selecciona tu idioma / Select your language" MSG_es_SPANISH="Espanol" MSG_es_ENGLISH="Ingles" MSG_es_SELECT_PRODUCT="Selecciona el producto" MSG_es_PROXY_DESC="Proxy central Traefik (se auto-instala con Central/Intercom)" MSG_es_CENTRAL_DESC="Plataforma de gestion de streaming (RTSP, HLS, WebRTC)" MSG_es_INTERCOM_DESC="Sistema de intercomunicacion WebRTC para broadcast" MSG_es_SELECT_ACTION="Selecciona la accion" MSG_es_INSTALL="Instalar" MSG_es_UPDATE="Actualizar" MSG_es_UNINSTALL="Desinstalar" MSG_es_STATUS="Ver estado" MSG_es_EXIT="Salir" MSG_es_INSTALL_DESC="Instalar la aplicacion desde cero" MSG_es_UPDATE_DESC="Actualizar a la ultima version" MSG_es_UNINSTALL_DESC="Eliminar la aplicacion completamente" MSG_es_STATUS_DESC="Ver el estado de los servicios" MSG_es_ALREADY_INSTALLED="ya esta instalado en" MSG_es_REINSTALL_QUESTION="Deseas reinstalar? (se eliminaran los datos actuales)" MSG_es_NOT_INSTALLED="no esta instalado" MSG_es_INSTALL_FIRST="Debes instalarlo primero" MSG_es_CONFIRM_UNINSTALL="Estas seguro de que deseas desinstalar" MSG_es_DELETE_DATA="Deseas eliminar tambien los datos (base de datos, configuracion)?" MSG_es_UNINSTALL_CANCELLED="Desinstalacion cancelada" MSG_es_DOWNLOADING="Descargando" MSG_es_STARTING_INSTALL="Iniciando instalacion de" MSG_es_STARTING_UPDATE="Iniciando actualizacion de" MSG_es_STARTING_UNINSTALL="Iniciando desinstalacion de" MSG_es_BACKUP_CONFIG="Creando backup de configuracion..." MSG_es_PULLING_IMAGES="Descargando nuevas imagenes..." MSG_es_RESTARTING="Reiniciando servicios..." MSG_es_CLEANING="Limpiando imagenes antiguas..." MSG_es_UPDATE_SUCCESS="actualizado correctamente" MSG_es_STOPPING="Deteniendo contenedores..." MSG_es_REMOVING_IMAGES="Eliminando imagenes..." MSG_es_REMOVING_DATA="Eliminando datos..." MSG_es_REMOVING_CONFIG="Eliminando configuracion..." MSG_es_UNINSTALL_SUCCESS="ha sido desinstalado correctamente" MSG_es_STATUS_TITLE="Estado de los servicios" MSG_es_SERVICE_RUNNING="EN EJECUCION" MSG_es_SERVICE_STOPPED="DETENIDO" MSG_es_PRESS_ENTER="Presiona Enter para continuar..." MSG_es_YES_NO="[s/N]" MSG_es_YES_DEFAULT="[S/n]" MSG_es_OPTION="Opcion" MSG_es_INVALID_OPTION="Opcion no valida" MSG_es_REQUIRES_ROOT="Este script debe ejecutarse como root" MSG_es_RUN_WITH_SUDO="Ejecuta: curl -fsSL $BASE_URL | sudo bash" MSG_es_VIEW_LOGS="Ver logs" MSG_es_LOGS_CMD="Comando para ver logs" MSG_es_PROXY_REQUIRED="NOTA: El Proxy Traefik se auto-instala con Central o Intercom" MSG_es_ARCHITECTURE_INFO="Arquitectura v2.0: Proxy auto-instalado + Apps con dominios separados" # --- ENGLISH --- MSG_en_WELCOME="Welcome to StreamingPro installer" MSG_en_SELECT_LANG="Selecciona tu idioma / Select your language" MSG_en_SPANISH="Spanish" MSG_en_ENGLISH="English" MSG_en_SELECT_PRODUCT="Select product" MSG_en_PROXY_DESC="Traefik central proxy (auto-installs with Central/Intercom)" MSG_en_CENTRAL_DESC="Streaming management platform (RTSP, HLS, WebRTC)" MSG_en_INTERCOM_DESC="WebRTC intercom system for broadcast" MSG_en_SELECT_ACTION="Select action" MSG_en_INSTALL="Install" MSG_en_UPDATE="Update" MSG_en_UNINSTALL="Uninstall" MSG_en_STATUS="View status" MSG_en_EXIT="Exit" MSG_en_INSTALL_DESC="Install the application from scratch" MSG_en_UPDATE_DESC="Update to the latest version" MSG_en_UNINSTALL_DESC="Remove the application completely" MSG_en_STATUS_DESC="View services status" MSG_en_ALREADY_INSTALLED="is already installed at" MSG_en_REINSTALL_QUESTION="Do you want to reinstall? (current data will be deleted)" MSG_en_NOT_INSTALLED="is not installed" MSG_en_INSTALL_FIRST="You must install it first" MSG_en_CONFIRM_UNINSTALL="Are you sure you want to uninstall" MSG_en_DELETE_DATA="Do you also want to delete data (database, configuration)?" MSG_en_UNINSTALL_CANCELLED="Uninstall cancelled" MSG_en_DOWNLOADING="Downloading" MSG_en_STARTING_INSTALL="Starting installation of" MSG_en_STARTING_UPDATE="Starting update of" MSG_en_STARTING_UNINSTALL="Starting uninstall of" MSG_en_BACKUP_CONFIG="Creating configuration backup..." MSG_en_PULLING_IMAGES="Downloading new images..." MSG_en_RESTARTING="Restarting services..." MSG_en_CLEANING="Cleaning old images..." MSG_en_UPDATE_SUCCESS="updated successfully" MSG_en_STOPPING="Stopping containers..." MSG_en_REMOVING_IMAGES="Removing images..." MSG_en_REMOVING_DATA="Removing data..." MSG_en_REMOVING_CONFIG="Removing configuration..." MSG_en_UNINSTALL_SUCCESS="has been uninstalled successfully" MSG_en_STATUS_TITLE="Services status" MSG_en_SERVICE_RUNNING="RUNNING" MSG_en_SERVICE_STOPPED="STOPPED" MSG_en_PRESS_ENTER="Press Enter to continue..." MSG_en_YES_NO="[y/N]" MSG_en_YES_DEFAULT="[Y/n]" MSG_en_OPTION="Option" MSG_en_INVALID_OPTION="Invalid option" MSG_en_REQUIRES_ROOT="This script must be run as root" MSG_en_RUN_WITH_SUDO="Run: curl -fsSL $BASE_URL | sudo bash" MSG_en_VIEW_LOGS="View logs" MSG_en_LOGS_CMD="Command to view logs" MSG_en_PROXY_REQUIRED="NOTE: Traefik Proxy auto-installs with Central or Intercom" MSG_en_ARCHITECTURE_INFO="Architecture v2.0: Auto-installed proxy + Apps with separate domains" # ============================================================================= # FUNCIONES DE UTILIDAD # ============================================================================= print_banner() { clear echo -e "${CYAN}" cat << "EOF" _____ _ _ ____ / ____| | (_) | _ \ | (___ | |_ _ __ ___ __ _ _ __ ___ _ _ __ __ _| |_) |_ __ ___ \___ \| __| '__/ _ \/ _` | '_ ` _ \| | '_ \ / _` | __/| '__/ _ \ ____) | |_| | | __/ (_| | | | | | | | | | | (_| | | | | | (_) | |_____/ \__|_| \___|\__,_|_| |_| |_|_|_| |_|\__, |_| |_| \___/ __/ | |___/ EOF echo -e "${NC}" echo -e "${WHITE} $(t WELCOME) v${VERSION}${NC}" echo -e "${BLUE} ════════════════════════════════════════════════════════════${NC}" echo -e "${YELLOW} $(t ARCHITECTURE_INFO)${NC}" echo "" } log_info() { echo -e "${BLUE}[INFO]${NC} $1" } log_success() { echo -e "${GREEN}[✓]${NC} $1" } log_warning() { echo -e "${YELLOW}[!]${NC} $1" } log_error() { echo -e "${RED}[✗]${NC} $1" } ask_yes_no() { local prompt="$1" local default="$2" local var_name="$3" local options if [ "$default" = "y" ]; then options=$(t YES_DEFAULT) else options=$(t YES_NO) fi echo -e -n "${WHITE}$prompt ${CYAN}$options${NC}: " read -r response /dev/null || true log_info "$(t PULLING_IMAGES)" docker compose pull log_info "$(t RESTARTING)" docker compose up -d log_info "$(t CLEANING)" docker image prune -f echo "" log_success "$product_name $(t UPDATE_SUCCESS)" echo "" echo -e "${WHITE}$(t LOGS_CMD):${NC}" echo -e " ${CYAN}cd $install_dir && docker compose logs -f${NC}" echo "" echo -e -n "$(t PRESS_ENTER)" read -r /dev/null || true ;; central) docker rmi sincros/central-backend:latest 2>/dev/null || true docker rmi sincros/central-frontend:latest 2>/dev/null || true docker rmi sincros/central-mediamtx:latest 2>/dev/null || true ;; intercom) docker rmi sincros/intercom-backend:latest 2>/dev/null || true docker rmi sincros/intercom-frontend:latest 2>/dev/null || true ;; esac if [ "$DELETE_DATA" = "true" ]; then log_info "$(t REMOVING_DATA)" rm -rf "$install_dir/data" fi log_info "$(t REMOVING_CONFIG)" rm -rf "$install_dir" # Si es proxy, eliminar la red compartida si no hay apps if [ "$product" = "proxy" ]; then if ! is_installed "central" && ! is_installed "intercom"; then docker network rm streamingpro-network 2>/dev/null || true fi fi echo "" log_success "$product_name $(t UNINSTALL_SUCCESS)" echo "" echo -e -n "$(t PRESS_ENTER)" read -r /dev/null) || true log_info "$(t REMOVING_CONFIG)..." rm -rf "$install_dir" log_success "Desinstalacion completada" fi } do_status() { local product="$1" local product_name local install_dir case "$product" in proxy) product_name="StreamingPro Proxy"; install_dir="$PROXY_DIR" ;; central) product_name="StreamingPro Central"; install_dir="$CENTRAL_DIR" ;; intercom) product_name="StreamingPro Intercom"; install_dir="$INTERCOM_DIR" ;; esac print_banner echo -e "${BLUE}═══════════════════════════════════════════════════════════${NC}" echo -e "${WHITE} $product_name - $(t STATUS_TITLE)${NC}" echo -e "${BLUE}═══════════════════════════════════════════════════════════${NC}" echo "" if ! is_installed "$product"; then log_warning "$product_name $(t NOT_INSTALLED)" else cd "$install_dir" docker compose ps fi echo "" echo -e -n "$(t PRESS_ENTER)" read -r