# --------------------------------------------------------- # core.ps1 - ORQUESTADOR PRINCIPAL v1.0.0 # --------------------------------------------------------- # 0. Privilegios y Logs if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Write-Host "`n[!] ERROR: Ejecuta como ADMINISTRADOR." -ForegroundColor Red; Pause; exit } # 1. Validación de Seguridad $ClaveMaestra = "7132" $MaxIntentos = 3 $AccesoValido = $false Clear-Host Write-Host "`n[SISTEMA] Verificando credenciales..." -ForegroundColor Cyan for ($i = 1; $i -le $MaxIntentos; $i++) { $inputPass = Read-Host " -> Introduce clave" -AsSecureString $p = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($inputPass)) if ($p -eq $ClaveMaestra) { $AccesoValido = $true; break } else { Write-Host " [!] Incorrecta ($i/$MaxIntentos)" -ForegroundColor Red } } if (-not $AccesoValido) { exit } # 2. Función Universal de Conexión a GitLab function Get-GitLabItem { param ([Parameter(Mandatory=$true)][string]$FilePath) $Branch = if ($Global:GitBranch) { $Global:GitBranch } else { "main" } $Url = "https://gitlab.com/api/v4/projects/80304083/repository/files/$([uri]::EscapeDataString($FilePath))/raw?ref=$Branch" $Headers = @{ "PRIVATE-TOKEN" = "glpat-_CjjGm3gO7XM1fubmcMBY286MQp1OmwyMTVzCw.01.1212nflx1" } try { return Invoke-RestMethod -Uri $Url -Headers $Headers -ErrorAction Stop } catch { return $null } } # 3. Carga de Configuración $settings = Get-GitLabItem -FilePath "config/settings.ps1" if ($settings) { Invoke-Expression $settings } else { Write-Host "ERROR CRÍTICO: No hay settings." -ForegroundColor Red; Pause; exit } function Write-AulaLog { param($msg) "$(Get-Date -Format 'HH:mm:ss') - $msg" | Out-File (Join-Path $Global:DirLogs "session.log") -Append } # 4. Menús (Rutas a /system) function Show-ConfigMenu { while ($true) { Clear-Host Write-Host "=== CONFIGURACIÓN DE SISTEMA ===" -ForegroundColor $Global:ColMenu Write-Host "1. Bootstrap FULL`n2. Solo Winget`n3. Solo Red/WinRM`nR. Volver" $op = Read-Host "`nSelección" if ($op -match '^[123]$') { $Global:BootMode = @{'1'='FULL'; '2'='WINGET'; '3'='CONFIG'}[$op] $c = Get-GitLabItem -FilePath "system/_bootstrap.ps1" if ($c) { Invoke-Expression $c } } elseif ($op.ToUpper() -eq 'R') { break } } } function Show-MainMenu { while ($true) { Clear-Host Write-Host "=== GESTOR DE AULAS v$($Global:SysVersion) ===" -ForegroundColor $Global:ColTitle Write-Host "1. Selección MANUAL`n2. BUNDLES (Aulas)`nC. Configuración`nQ. Salir" $op = Read-Host "`nSelección" switch ($op.ToUpper()) { '1' { $c = Get-GitLabItem -FilePath "system/_select.ps1"; if ($c) { Invoke-Expression $c } } '2' { Write-Host "Próximamente..." -ForegroundColor Yellow; Start-Sleep 2 } 'C' { Show-ConfigMenu } 'Q' { exit } } } } Write-AulaLog "Sistema iniciado." Show-MainMenu