# ZimaOS Blue Install/Update Script for Windows # Usage: irm https://ota.zimaos.com/blue/windows | iex $ErrorActionPreference = "Stop" $Version = "0.10.39" $DownloadBase = "https://github.com/IceWhaleTech/ZimaOS-Blue/releases/download/0.10.39" $InstallDir = Join-Path $env:LOCALAPPDATA "ZimaOS-Blue" $BinaryName = "blue.exe" $ProcessName = "blue" function Write-Info($msg) { Write-Host "[INFO] $msg" -ForegroundColor Cyan } function Write-Ok($msg) { Write-Host "[OK] $msg" -ForegroundColor Green } function Write-Warn($msg) { Write-Host "[WARN] $msg" -ForegroundColor Yellow } $isZh = (Get-Culture).Name -like "zh-*" function Msg($key, $arg) { switch ($key) { "installer" { if ($isZh) { "ZimaOS Blue 安装程序 v$arg" } else { "ZimaOS Blue installer v$arg" } } "platform" { if ($isZh) { "平台: $arg" } else { "Platform: $arg" } } "stopping" { if ($isZh) { "发现已运行的 Blue 进程,正在停止以进行更新..." } else { "Existing Blue process found, stopping for update..." } } "downloading" { if ($isZh) { "正在下载 $arg..." } else { "Downloading $arg..." } } "extracting" { if ($isZh) { "正在解压..." } else { "Extracting..." } } "not_found" { if ($isZh) { "在压缩包中找不到 blue 可执行文件" } else { "Could not find blue binary in archive" } } "starting" { if ($isZh) { "正在启动 Blue..." } else { "Starting Blue..." } } "updated" { if ($isZh) { "Blue 已更新到 v$arg 并重新启动!" } else { "Blue updated to v$arg and restarted!" } } "installed" { if ($isZh) { "Blue v$arg 已安装并启动!" } else { "Blue v$arg installed and started!" } } "open_prompt" { if ($isZh) { "按回车键在浏览器中打开 $arg(关闭窗口跳过)..." } else { "Press Enter to open $arg in your browser (or close this window to skip)..." } } "path_warn" { if ($isZh) { "$arg 不在你的 PATH 中" } else { "$arg is not in your PATH" } } "path_hint" { if ($isZh) { "运行以下命令添加: [Environment]::SetEnvironmentVariable('Path', `"$arg`", 'User')" } else { "Run to add: [Environment]::SetEnvironmentVariable('Path', `"$arg`", 'User')" } } } } Write-Info (Msg "installer" $Version) Write-Info (Msg "platform" "windows/amd64") if (-not (Test-Path $InstallDir)) { New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null } $isUpdate = $false $existing = Get-Process -Name $ProcessName -ErrorAction SilentlyContinue if ($existing) { $isUpdate = $true Write-Info (Msg "stopping") Stop-Process -Name $ProcessName -Force -ErrorAction SilentlyContinue Start-Sleep -Seconds 1 } $pkg = "blue-$Version-windows-amd64.zip" $url = "$DownloadBase/$pkg" $tmpDir = Join-Path $env:TEMP "zimaos-blue-install" if (Test-Path $tmpDir) { Remove-Item -Recurse -Force $tmpDir } New-Item -ItemType Directory -Path $tmpDir -Force | Out-Null $zipPath = Join-Path $tmpDir $pkg Write-Info (Msg "downloading" $pkg) Invoke-WebRequest -Uri $url -OutFile $zipPath -UseBasicParsing Write-Info (Msg "extracting") Expand-Archive -Path $zipPath -DestinationPath $tmpDir -Force $found = Get-ChildItem -Path $tmpDir -Recurse -Filter "blue.exe" | Select-Object -First 1 if (-not $found) { $found = Get-ChildItem -Path $tmpDir -Recurse -Filter "blue" | Select-Object -First 1 } if ($found) { Copy-Item -Path $found.FullName -Destination (Join-Path $InstallDir $BinaryName) -Force } else { Write-Host "[ERROR] $(Msg "not_found")" -ForegroundColor Red Remove-Item -Recurse -Force $tmpDir exit 1 } Remove-Item -Recurse -Force $tmpDir Write-Info (Msg "starting") Start-Process -FilePath (Join-Path $InstallDir $BinaryName) -WindowStyle Hidden Start-Sleep -Seconds 2 if ($isUpdate) { Write-Ok (Msg "updated" $Version) } else { Write-Ok (Msg "installed" $Version) } Write-Host "[INFO] $(Msg "open_prompt" "http://localhost")" -ForegroundColor Cyan Read-Host Start-Process "http://localhost" $userPath = [Environment]::GetEnvironmentVariable("Path", "User") if ($userPath -notlike "*$InstallDir*") { Write-Warn (Msg "path_warn" $InstallDir) Write-Warn (Msg "path_hint" "$userPath;$InstallDir") }