| |
| |
|
|
| $ErrorActionPreference = "Stop" |
| $INSTALL_PATH = "C:\AI-LAB" |
| $SCRIPT_NAME = "boot.ps1" |
| $FULL_SCRIPT_PATH = Join-Path $INSTALL_PATH $SCRIPT_NAME |
| $REPO_RAW_URL = "https://huggingface.co/vost/pub-scripts/raw/main/" |
|
|
| |
| if (-not (Test-Path $INSTALL_PATH)) { |
| New-Item -Path $INSTALL_PATH -ItemType Directory -Force | Out-Null |
| } |
| Set-Location $INSTALL_PATH |
|
|
| |
| if (-not (Get-Command docker -ErrorAction SilentlyContinue)) { |
| if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { |
| Write-Host "Docker não encontrado. Solicitando permissões de Administrador..." -ForegroundColor Cyan |
| Start-Process powershell.exe -ArgumentList "-ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs |
| exit |
| } |
| Write-Host "Instalando Docker Desktop..." -ForegroundColor Yellow |
| winget install --id Docker.DockerDesktop --silent --accept-package-agreements |
| Write-Host "REINICIE o computador e execute o AI-LAB novamente." -ForegroundColor Red |
| exit |
| } |
|
|
| |
| function Sync-RemoteFile { |
| param ( |
| [Parameter(Mandatory=$true)][string]$FileName, |
| [Parameter(Mandatory=$true)][string]$DestinationPath, |
| [switch]$RestartOnUpdate |
| ) |
| $RemoteUrl = "$REPO_RAW_URL$FileName" |
| $TempFile = Join-Path $env:TEMP "ai-lab-$FileName" |
| try { |
| if (Test-Path $DestinationPath) { |
| Invoke-WebRequest -Uri $RemoteUrl -OutFile $TempFile -UseBasicParsing |
| $localHash = (Get-FileHash $DestinationPath -Algorithm SHA256).Hash |
| $remoteHash = (Get-FileHash $TempFile -Algorithm SHA256).Hash |
|
|
| if ($localHash -ne $remoteHash) { |
| Write-Host "Atualizando [$FileName]..." -ForegroundColor Magenta |
| Move-Item -Path $TempFile -Destination $DestinationPath -Force |
| if ($RestartOnUpdate) { |
| Start-Process powershell.exe -ArgumentList "-ExecutionPolicy Bypass -File `"$DestinationPath`"" |
| exit |
| } |
| } |
| } else { |
| Write-Host "Baixando [$FileName]..." -ForegroundColor Cyan |
| New-Item -ItemType File -Path $DestinationPath -Force | Out-Null |
| Invoke-WebRequest -Uri $RemoteUrl -OutFile $DestinationPath -UseBasicParsing |
| } |
| } catch { Write-Warning "Falha ao sincronizar [$FileName]." } |
| } |
|
|
| |
| Sync-RemoteFile -FileName $SCRIPT_NAME -DestinationPath $FULL_SCRIPT_PATH -RestartOnUpdate |
|
|
| |
| if (-not [Environment]::GetEnvironmentVariable("HF_TOKEN", "User")) { |
| $token = Read-Host "Insira seu HuggingFace Token (Read)" |
| [Environment]::SetEnvironmentVariable("HF_TOKEN", $token, "User") |
| } |
|
|
| |
| Write-Host "--- Preparando Infraestrutura ---" -ForegroundColor Cyan |
|
|
| $CURRENT_PATH = $PSScriptRoot.Replace('\', '/') |
| $CURRENT_PATH = $CURRENT_PATH.TrimStart('/') |
| $env:HOST_AI_LAB_PATH = $CURRENT_PATH |
| Write-Host "VARIAVEL DEFINIDA: $env:HOST_AI_LAB_PATH" -ForegroundColor Yellow |
| |
| [Environment]::SetEnvironmentVariable("HOST_AI_LAB_PATH", $CURRENT_PATH, "Process") |
|
|
| if (-not (docker volume ls -q -f name=Guardians-Share)) { |
| Write-Host "Criando Volume Compartilhado (Guardians-Share)..." -ForegroundColor Gray |
| docker volume create Guardians-Share |
| } |
|
|
| |
| Write-Host "--- Iniciando HW-Guardian ---" -ForegroundColor Green |
| $HWGUARDIAN_DIR = "$INSTALL_PATH\Guardians\HW-Guardian" |
| if (Test-Path $HWGUARDIAN_DIR) { |
| docker build -t hw-guardian-base "$HWGUARDIAN_DIR" |
| docker compose -f "$HWGUARDIAN_DIR\docker-compose.yaml" up -d |
| } |
|
|
| |
| Write-Host "--- Iniciando AI-Guardian ---" -ForegroundColor Magenta |
| $AIGUARDIAN_DIR = "$INSTALL_PATH\Guardians\AI-Guardian" |
| if (Test-Path $AIGUARDIAN_DIR) { |
| docker build -t ai-guardian-base "$AIGUARDIAN_DIR" |
| docker compose -f "$AIGUARDIAN_DIR\docker-compose.yaml" up -d |
| } |
|
|
| |
| $ShortcutPath = Join-Path ([Environment]::GetFolderPath("Desktop")) "AI-LAB.lnk" |
| if (-not (Test-Path $ShortcutPath)) { |
| $WshShell = New-Object -ComObject WScript.Shell |
| $Shortcut = $WshShell.CreateShortcut($ShortcutPath) |
| $Shortcut.TargetPath = "powershell.exe" |
| $Shortcut.Arguments = "-ExecutionPolicy Bypass -File `"$FULL_SCRIPT_PATH`"" |
| $Shortcut.WorkingDirectory = $INSTALL_PATH |
| $Shortcut.Save() |
| } |
|
|
| Write-Host "`n[SUCESSO] AI-LAB Ativo. Pressione qualquer tecla..." -ForegroundColor Green |
| $null = [System.Console]::ReadKey() |