# SCORPIOX CODE - https://code.scorpiox.net # Usage: iwr -useb get.scorpiox.net | iex $ErrorActionPreference = "Stop" [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $ProgressPreference = 'SilentlyContinue' $IndexUrl = "https://dist.scorpiox.net/scorpiox/index.txt" $FallbackBranch = "main" # Fetch default branch dynamically try { $Branch = (Invoke-WebRequest -Uri $IndexUrl -UseBasicParsing -TimeoutSec 10).Content.Trim() if ([string]::IsNullOrWhiteSpace($Branch)) { $Branch = $FallbackBranch } } catch { $Branch = $FallbackBranch } $ZipUrl = "https://dist.scorpiox.net/scorpiox/$Branch/scorpiox_code_windows.zip" $InstallDir = "$env:LOCALAPPDATA\scorpiox" $ZipPath = "$env:TEMP\scorpiox_code_windows.zip" Write-Host "" Write-Host " ___ _ __ __" -ForegroundColor Cyan Write-Host " / __| __ ___ _ _ _ __ (_) ___ \ \/ /" -ForegroundColor Cyan Write-Host " \__ \/ _/ _ \| '_| '_ \ | |/ _ \ > < " -ForegroundColor Cyan Write-Host " |___/\__\___/|_| | .__/ |_|\___//_/\_\" -ForegroundColor Cyan Write-Host " |_| " -ForegroundColor Cyan Write-Host "" Write-Host " SCORPIOX CODE (branch: $Branch)" -ForegroundColor White Write-Host "" # Step 1: Create install directory Write-Host "[1/6] Creating install directory..." -ForegroundColor Yellow if (!(Test-Path $InstallDir)) { New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null } Write-Host " $InstallDir" -ForegroundColor Green # Step 2: Download zip Write-Host "[2/6] Downloading SCORPIOX CODE (~18 MB)..." -ForegroundColor Yellow try { Invoke-WebRequest -Uri $ZipUrl -OutFile $ZipPath -UseBasicParsing Write-Host " Downloaded successfully" -ForegroundColor Green } catch { Write-Host " Download failed: $_" -ForegroundColor Red exit 1 } # SHA256 checksum verification $ShaUrl = "$ZipUrl.sha256" try { $Expected = (Invoke-WebRequest -Uri $ShaUrl -UseBasicParsing -TimeoutSec 10).Content.Trim().Split(" ")[0] $Actual = (Get-FileHash -Algorithm SHA256 $ZipPath).Hash.ToLower() if ($Expected -ne $Actual) { Write-Host " ERROR: SHA256 checksum mismatch!" -ForegroundColor Red Remove-Item $ZipPath -Force -ErrorAction SilentlyContinue exit 1 } Write-Host " SHA256 verified OK" -ForegroundColor Green } catch { Write-Host " ERROR: Could not verify checksum — aborting" -ForegroundColor Red Remove-Item $ZipPath -Force -ErrorAction SilentlyContinue exit 1 } # Step 3: Extract zip Write-Host "[3/6] Extracting to $InstallDir..." -ForegroundColor Yellow try { Expand-Archive -Path $ZipPath -DestinationPath $InstallDir -Force Remove-Item $ZipPath -Force -ErrorAction SilentlyContinue $fileCount = (Get-ChildItem -Path $InstallDir -File).Count Write-Host " Extracted $fileCount files" -ForegroundColor Green } catch { Write-Host " Extraction failed: $_" -ForegroundColor Red Remove-Item $ZipPath -Force -ErrorAction SilentlyContinue exit 1 } # Step 4: Add to PATH and create updater Write-Host "[4/6] Setting up PATH..." -ForegroundColor Yellow $userPath = [Environment]::GetEnvironmentVariable("PATH", "User") if ($userPath -notlike "*$InstallDir*") { [Environment]::SetEnvironmentVariable("PATH", "$InstallDir;$userPath", "User") $env:PATH = "$InstallDir;$env:PATH" Write-Host " Added to PATH" -ForegroundColor Green } else { Write-Host " Already in PATH" -ForegroundColor Green } $BinDir = "$InstallDir\bin" if ($userPath -notlike "*$BinDir*") { $updatedPath = [Environment]::GetEnvironmentVariable("PATH", "User") [Environment]::SetEnvironmentVariable("PATH", "$BinDir;$updatedPath", "User") $env:PATH = "$BinDir;$env:PATH" Write-Host " Added bin to PATH" -ForegroundColor Green } else { Write-Host " bin already in PATH" -ForegroundColor Green } # Step 5: Create scorpiox-update Write-Host "[5/6] Setting up scorpiox-update..." -ForegroundColor Yellow $UpdateScript = @' # SCORPIOX CODE Updater # Usage: scorpiox-update [branch] or scorpiox-update --commit $ErrorActionPreference = "Stop" [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $ProgressPreference = 'SilentlyContinue' $IndexUrl = "https://dist.scorpiox.net/scorpiox/index.txt" $FallbackBranch = "main" # Parse arguments $CommitHash = "" $Branch = "" for ($i = 0; $i -lt $args.Count; $i++) { switch ($args[$i]) { "--dump" { Get-Content -Path $MyInvocation.MyCommand.Path; exit 0 } "--commit" { $i++; $CommitHash = $args[$i] } default { $Branch = $args[$i] } } } # Build the download URL if ($CommitHash -ne "") { $ZipUrl = "https://dist.scorpiox.net/scorpiox/builds/$CommitHash/scorpiox_code_windows.zip" Write-Host "Updating SCORPIOX CODE (commit: $CommitHash)..." -ForegroundColor Cyan } else { if ($Branch -eq "") { try { $Branch = (Invoke-WebRequest -Uri $IndexUrl -UseBasicParsing -TimeoutSec 10).Content.Trim() if ([string]::IsNullOrWhiteSpace($Branch)) { $Branch = $FallbackBranch } } catch { $Branch = $FallbackBranch } } $ZipUrl = "https://dist.scorpiox.net/scorpiox/$Branch/scorpiox_code_windows.zip" Write-Host "Updating SCORPIOX CODE (branch: $Branch)..." -ForegroundColor Cyan } $InstallDir = "$env:LOCALAPPDATA\scorpiox" $ZipPath = "$env:TEMP\scorpiox_code_windows.zip" try { Invoke-WebRequest -Uri $ZipUrl -OutFile $ZipPath -UseBasicParsing } catch { Write-Host "Download failed: $_" -ForegroundColor Red exit 1 } # SHA256 checksum verification $ShaUrl = "$ZipUrl.sha256" try { $Expected = (Invoke-WebRequest -Uri $ShaUrl -UseBasicParsing -TimeoutSec 10).Content.Trim().Split(" ")[0] $Actual = (Get-FileHash -Algorithm SHA256 $ZipPath).Hash.ToLower() if ($Expected -ne $Actual) { Write-Host "ERROR: SHA256 checksum mismatch!" -ForegroundColor Red Remove-Item $ZipPath -Force -ErrorAction SilentlyContinue exit 1 } Write-Host "SHA256 verified OK" -ForegroundColor Green } catch { Write-Host "ERROR: Could not verify checksum — aborting" -ForegroundColor Red Remove-Item $ZipPath -Force -ErrorAction SilentlyContinue exit 1 } try { Expand-Archive -Path $ZipPath -DestinationPath $InstallDir -Force Remove-Item $ZipPath -Force -ErrorAction SilentlyContinue Write-Host "SCORPIOX CODE updated successfully!" -ForegroundColor Green } catch { Write-Host "Update failed: $_" -ForegroundColor Red Remove-Item $ZipPath -Force -ErrorAction SilentlyContinue exit 1 } '@ $UpdatePath = "$InstallDir\scorpiox-update.ps1" Set-Content -Path $UpdatePath -Value $UpdateScript -Encoding UTF8 # Create .cmd wrapper so it works without typing .ps1 $CmdWrapper = "@echo off`r`npowershell -ExecutionPolicy Bypass -File `"%~dp0scorpiox-update.ps1`" %*" Set-Content -Path "$InstallDir\scorpiox-update.cmd" -Value $CmdWrapper -Encoding ASCII Write-Host " Created scorpiox-update" -ForegroundColor Green # Done # Step 6: Create scorpiox-uninstall Write-Host "[6/6] Setting up scorpiox-uninstall..." -ForegroundColor Yellow $UninstallScript = @' # Uninstall SCORPIOX CODE $ErrorActionPreference = "Stop" $InstallDir = "$env:LOCALAPPDATA\scorpiox" Write-Host "" Write-Host "Uninstalling SCORPIOX CODE..." -ForegroundColor Yellow Write-Host "" # Remove all scorpiox files if (Test-Path $InstallDir) { $fileCount = (Get-ChildItem -Path $InstallDir -File -ErrorAction SilentlyContinue).Count Remove-Item -Recurse -Force $InstallDir -ErrorAction SilentlyContinue Write-Host " Removed $fileCount files from $InstallDir" -ForegroundColor Green } else { Write-Host " Install directory not found: $InstallDir" -ForegroundColor Yellow } # Remove from PATH $UserPath = [Environment]::GetEnvironmentVariable("PATH", "User") if ($UserPath -and $UserPath.Contains($InstallDir)) { $NewPath = ($UserPath.Split(";") | Where-Object { $_ -ne $InstallDir }) -join ";" [Environment]::SetEnvironmentVariable("PATH", $NewPath, "User") Write-Host " Removed from PATH" -ForegroundColor Green } # Ask about user data $UserData = "$env:USERPROFILE\.scorpiox" if (Test-Path $UserData) { Write-Host "" Write-Host " User data exists at $UserData" -ForegroundColor Yellow Write-Host " (sessions, logs, config)" $answer = Read-Host " Remove user data? [y/N]" if ($answer -eq "y" -or $answer -eq "Y") { Remove-Item -Recurse -Force $UserData -ErrorAction SilentlyContinue Write-Host " Removed $UserData" -ForegroundColor Green } else { Write-Host " Kept $UserData" -ForegroundColor Gray } } Write-Host "" Write-Host "SCORPIOX CODE uninstalled." -ForegroundColor Green '@ $UninstallPath = "$InstallDir\scorpiox-uninstall.ps1" Set-Content -Path $UninstallPath -Value $UninstallScript -Encoding UTF8 # Create .cmd wrapper $CmdWrapper = "@echo off`r`npowershell -ExecutionPolicy Bypass -File `"%~dp0scorpiox-uninstall.ps1`" %*" Set-Content -Path "$InstallDir\scorpiox-uninstall.cmd" -Value $CmdWrapper -Encoding ASCII Write-Host " Created scorpiox-uninstall" -ForegroundColor Green Write-Host "" Write-Host "==========================================" -ForegroundColor Cyan Write-Host " Installation complete!" -ForegroundColor Green Write-Host "==========================================" -ForegroundColor Cyan Write-Host "" Write-Host " Open a NEW PowerShell window and run:" -ForegroundColor Yellow Write-Host "" Write-Host " sx Main CLI" -ForegroundColor Cyan Write-Host " scorpiox-wsl WSL container mode" -ForegroundColor Cyan Write-Host " scorpiox-update Update to latest" -ForegroundColor Cyan Write-Host " scorpiox-uninstall Remove everything" -ForegroundColor Cyan Write-Host ""