# --------------------------------------------------------- # core.ps1 - BOOTSTRAPPER Y MENÚ PRINCIPAL (Todo en memoria) # --------------------------------------------------------- # --- CONFIGURACIÓN DE SEGURIDAD --- $ClaveMaestra = "7132" # <-- CAMBIA ESTO por la contraseña que quieras $MaxIntentos = 3 $AccesoValido = $false Clear-Host Write-Host "`n[SISTEMA] Verificando credenciales de acceso..." -ForegroundColor Cyan for ($i = 1; $i -le $MaxIntentos; $i++) { $inputPass = Read-Host " -> Introduce la clave del Gestor de Aulas" -AsSecureString # Conversión segura para validación $BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($inputPass) $plainPass = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR) if ($plainPass -eq $ClaveMaestra) { $AccesoValido = $true Write-Host " [OK] Acceso concedido." -ForegroundColor Green break } else { Write-Host " [!] Clave incorrecta. Intento $i de $MaxIntentos." -ForegroundColor Red } } if (-not $AccesoValido) { Write-Host "`n[ERROR] Acceso denegado. Abortando ejecución." -ForegroundColor DarkRed exit } # ---------------------------------- # 1. Variables Globales $Global:GitLabToken = "glpat-_CjjGm3gO7XM1fubmcMBY286MQp1OmwyMTVzCw.01.1212nflx1" $Global:ProjectID = "80304083" $Global:TempSelectionFile = "$env:TEMP\aula_seleccion_paquetes.csv" $Global:HFToken = "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" # 2. Motor de conexión a GitLab function Get-GitLabItem { param ([Parameter(Mandatory=$true)][string]$FilePath) $EncodedPath = [uri]::EscapeDataString($FilePath) $Url = "https://gitlab.com/api/v4/projects/$Global:ProjectID/repository/files/$EncodedPath/raw?ref=main" $Headers = @{ "PRIVATE-TOKEN" = $Global:GitLabToken } try { return Invoke-RestMethod -Uri $Url -Headers $Headers -ErrorAction Stop } catch { Write-Host "`n[ERROR] No se pudo descargar el archivo: $FilePath" -ForegroundColor Red return $null } } # 3. Submenú de Configuración function Show-ConfigMenu { $configLoop = $true while ($configLoop) { Clear-Host Write-Host "========================================" -ForegroundColor Magenta Write-Host " GESTOR DE AULAS - CONFIGURACIÓN" Write-Host "========================================" -ForegroundColor Magenta Write-Host "1. Preparar equipo base COMPLETO" Write-Host "2. Instalar SÓLO Winget y dependencias" Write-Host "3. Configurar SÓLO red, firewall y WinRM" Write-Host "R. Volver al menú principal" Write-Host "----------------------------------------" -ForegroundColor Magenta $opcion = Read-Host "`nElige una opción" if ($opcion -match '^[123]$') { if ($opcion -eq '1') { $Global:BootMode = "FULL" } if ($opcion -eq '2') { $Global:BootMode = "WINGET" } if ($opcion -eq '3') { $Global:BootMode = "CONFIG" } $bootstrapScriptContent = Get-GitLabItem -FilePath "scripts/_bootstrap.ps1" if ($bootstrapScriptContent) { Invoke-Expression $bootstrapScriptContent } else { Pause } } elseif ($opcion.ToUpper() -eq 'R') { $configLoop = $false } } } # 4. Menú Principal function Show-MainMenu { $menuLoop = $true while ($menuLoop) { Clear-Host Write-Host "========================================" -ForegroundColor Cyan Write-Host " SISTEMA DE DESPLIEGUE - CORE" Write-Host "========================================" -ForegroundColor Cyan Write-Host "1. Instalación MANUAL (Selección de software)" Write-Host "2. Instalación BUNDLES" Write-Host "C. Configuración" Write-Host "Q. Salir" Write-Host "----------------------------------------" -ForegroundColor Cyan $opcion = Read-Host "Selecciona una opción" switch ($opcion.ToUpper()) { '1' { $selectScriptContent = Get-GitLabItem -FilePath "scripts/_select.ps1" if ($selectScriptContent) { Invoke-Expression $selectScriptContent } else { Pause } } '2' { Write-Host "`n[INFO] Opción BUNDLES pendiente de desarrollo..." -ForegroundColor Yellow Start-Sleep -Seconds 2 } 'C' { Show-ConfigMenu } 'Q' { $menuLoop = $false } default { Write-Host "`nOpción no válida." -ForegroundColor Red Start-Sleep -Seconds 1 } } } } # Iniciar el sistema Show-MainMenu