# Install Caedos on Windows. In PowerShell: # # irm https://caedos.com/install.ps1 | iex # # This downloads the Windows build from the latest release at # https://github.com/caedos-os/caedos-run/releases, checks it against the # release's SHA256SUMS, puts it in %LOCALAPPDATA%\Programs\Caedos with its # license and notices, and adds that folder to your PATH. It needs no # administrator rights, and it changes nothing else. # # Settings: # $env:CAEDOS_VERSION = 'v0.1.0' install that release instead of the latest # $env:CAEDOS_INSTALL_DIR = '' install there instead # # The Windows build isn't code-signed yet. Where Smart App Control is on, # Windows blocks it, and there's no way past that while it stays on. & { $ErrorActionPreference = 'Stop' # The progress bar makes downloads crawl in Windows PowerShell 5. $ProgressPreference = 'SilentlyContinue' [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 if ($env:OS -ne 'Windows_NT') { throw 'This script is for Windows. On macOS or Linux, run: curl -fsSL https://caedos.com/install.sh | sh' } $releases = 'https://github.com/caedos-os/caedos-run/releases' $version = $env:CAEDOS_VERSION $from = if (-not $version) { "$releases/latest/download" } elseif ($version.StartsWith('v')) { "$releases/download/$version" } else { "$releases/download/v$version" } $name = 'caedos-windows-x64' $dir = if ($env:CAEDOS_INSTALL_DIR) { $env:CAEDOS_INSTALL_DIR } else { Join-Path $env:LOCALAPPDATA 'Programs\Caedos' } $exe = Join-Path $dir 'caedos.exe' $tmp = Join-Path ([IO.Path]::GetTempPath()) ('caedos-' + [Guid]::NewGuid()) New-Item -ItemType Directory $tmp | Out-Null try { Write-Host "Downloading $name.zip" foreach ($file in "$name.zip", 'SHA256SUMS') { try { Invoke-WebRequest "$from/$file" -OutFile (Join-Path $tmp $file) -UseBasicParsing } catch { throw "Couldn't download $from/$file ($($_.Exception.Message))" } } $want = foreach ($line in Get-Content (Join-Path $tmp 'SHA256SUMS')) { $hash, $listed = $line -split '\s+\*?', 2 if ($listed -eq "$name.zip") { $hash } } $got = (Get-FileHash (Join-Path $tmp "$name.zip") -Algorithm SHA256).Hash if (-not $want -or $got -ne $want) { throw "$name.zip doesn't match SHA256SUMS. Nothing was installed." } Write-Host 'Checksum OK' Expand-Archive (Join-Path $tmp "$name.zip") $tmp New-Item -ItemType Directory -Force $dir | Out-Null # Windows lets a running program be renamed but not replaced, so a copy # that's running moves aside, and goes the next time this runs. Get-ChildItem $dir -Filter 'caedos.old*.exe' | Remove-Item -ErrorAction SilentlyContinue if (Test-Path $exe) { try { Remove-Item $exe } catch { Rename-Item $exe ('caedos.old' + (Get-Random) + '.exe') } } Copy-Item (Join-Path $tmp "$name\*") $dir -Force } finally { Remove-Item $tmp -Recurse -Force -ErrorAction SilentlyContinue } # Add the folder to your PATH, keeping any %VARIABLES% already in it as they are. $key = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey('Environment', $true) $userPath = $key.GetValue('Path', '', 'DoNotExpandEnvironmentNames') if (($userPath -split ';') -notcontains $dir) { $key.SetValue('Path', ((@($userPath.TrimEnd(';'), $dir) | Where-Object { $_ }) -join ';'), 'ExpandString') # Setting a variable this way tells open programs that the environment changed. [Environment]::SetEnvironmentVariable('CAEDOS_INSTALLING', '1', 'User') [Environment]::SetEnvironmentVariable('CAEDOS_INSTALLING', $null, 'User') } $key.Close() if (($env:Path -split ';') -notcontains $dir) { $env:Path = "$env:Path;$dir" } try { $installed = (& $exe version) -join ' ' } catch { throw "caedos.exe is in $dir, but Windows didn't run it: $($_.Exception.Message) Where Smart App Control is on, it blocks this unsigned build." } Write-Host "Installed $installed in $dir" Write-Host '' Write-Host 'Start it: caedos start' Write-Host 'Then connect your AI: https://caedos.com/start' }