-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbootstrap.ps1
More file actions
145 lines (122 loc) · 6.05 KB
/
bootstrap.ps1
File metadata and controls
145 lines (122 loc) · 6.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# Continuum Bootstrap for Windows — One command to install and launch.
#
# Usage (from PowerShell):
# irm https://raw.githubusercontent.com/CambrianTech/continuum/main/bootstrap.ps1 | iex
#
# Or with options:
# $env:CONTINUUM_MODE="headless"; irm ... | iex
# $env:CONTINUUM_MODE="cli"; irm ... | iex
# $env:CONTINUUM_MODE="browser"; irm ... | iex (default)
#
# What it does:
# 1. Ensures WSL2 + Ubuntu are installed (GPU passthrough for CUDA)
# 2. Hands off to bootstrap.sh inside WSL — same path as Linux
#
# Why WSL2:
# Continuum uses Unix sockets, Rust workers, and Metal/CUDA GPU compute.
# Native Windows cannot provide these. WSL2 runs a real Linux kernel with
# full CUDA passthrough via nvidia-smi — same performance as bare metal.
$ErrorActionPreference = "Stop"
$Mode = if ($env:CONTINUUM_MODE) { $env:CONTINUUM_MODE } else { "browser" }
Write-Host ""
Write-Host " Continuum Bootstrap (Windows)" -ForegroundColor Cyan
Write-Host " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor Cyan
Write-Host ""
Write-Host " Mode: $Mode" -ForegroundColor Green
Write-Host ""
# Clean up RunOnce continuation script if this is a post-restart run
$continuationPath = "$env:USERPROFILE\.continuum-bootstrap-continue.ps1"
if (Test-Path $continuationPath) {
Remove-Item $continuationPath -Force
}
# ============================================================================
# Step 1: Check if WSL2 + Ubuntu are ready
# ============================================================================
$wslExe = Get-Command wsl.exe -ErrorAction SilentlyContinue
if ($wslExe) {
# WSL exists — check for Ubuntu distro
$distros = wsl.exe --list --quiet 2>$null
$hasUbuntu = $distros | Where-Object { $_ -match "Ubuntu" }
if ($hasUbuntu) {
# WSL2 + Ubuntu ready — run bootstrap inside it
Write-Host " WSL2 + Ubuntu detected" -ForegroundColor Green
Write-Host " Launching Continuum install inside Linux..." -ForegroundColor Yellow
Write-Host ""
wsl.exe bash -ic "curl -fsSL https://raw.githubusercontent.com/CambrianTech/continuum/main/bootstrap.sh | bash -s -- --mode=$Mode"
if ($LASTEXITCODE -eq 0) {
Write-Host ""
Write-Host " Continuum is running!" -ForegroundColor Green
Write-Host " UI: http://localhost:9000" -ForegroundColor Green
Write-Host ""
}
exit $LASTEXITCODE
}
}
# ============================================================================
# Step 2: Install WSL2 + Ubuntu
# ============================================================================
Write-Host " WSL2 not found — installing..." -ForegroundColor Yellow
Write-Host ""
Write-Host " This requires administrator privileges." -ForegroundColor Yellow
Write-Host " Windows will install WSL2 + Ubuntu (full Linux with GPU passthrough)." -ForegroundColor Gray
Write-Host ""
# Check if running as admin
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(
[Security.Principal.WindowsBuiltInRole]::Administrator
)
if (-not $isAdmin) {
# Re-launch as admin, passing this script
Write-Host " Requesting administrator access..." -ForegroundColor Yellow
# Save continuation script that runs after WSL install + restart
$continuationScript = @"
# Auto-continue Continuum install after WSL2 restart
`$env:CONTINUUM_MODE = "$Mode"
irm https://raw.githubusercontent.com/CambrianTech/continuum/main/bootstrap.ps1 | iex
"@
$continuationPath = "$env:USERPROFILE\.continuum-bootstrap-continue.ps1"
$continuationScript | Out-File -FilePath $continuationPath -Encoding UTF8
# Schedule RunOnce to auto-continue after restart
$runOnceCmd = "powershell.exe -ExecutionPolicy Bypass -File `"$continuationPath`""
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\RunOnce" `
-Name "ContinuumBootstrap" `
-Value $runOnceCmd `
-PropertyType String `
-Force | Out-Null
# Elevate to install WSL
Start-Process -Verb RunAs -FilePath "wsl.exe" -ArgumentList "--install --distribution Ubuntu" -Wait
Write-Host ""
Write-Host " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor Green
Write-Host " WSL2 + Ubuntu installed!" -ForegroundColor Green
Write-Host " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor Green
Write-Host ""
Write-Host " Restart your computer to finish WSL2 kernel setup." -ForegroundColor Yellow
Write-Host " After restart, Continuum install will continue automatically." -ForegroundColor Gray
Write-Host ""
Write-Host " (A RunOnce task has been scheduled — you don't need to" -ForegroundColor Gray
Write-Host " remember any commands. Just restart and wait.)" -ForegroundColor Gray
Write-Host ""
exit 0
} else {
# Already admin — install directly
wsl.exe --install --distribution Ubuntu
Write-Host ""
Write-Host " WSL2 + Ubuntu installed!" -ForegroundColor Green
Write-Host ""
Write-Host " Restart your computer to finish WSL2 kernel setup." -ForegroundColor Yellow
Write-Host " After restart, Continuum install will continue automatically." -ForegroundColor Gray
Write-Host ""
# Schedule RunOnce
$continuationScript = @"
`$env:CONTINUUM_MODE = "$Mode"
irm https://raw.githubusercontent.com/CambrianTech/continuum/main/bootstrap.ps1 | iex
"@
$continuationPath = "$env:USERPROFILE\.continuum-bootstrap-continue.ps1"
$continuationScript | Out-File -FilePath $continuationPath -Encoding UTF8
$runOnceCmd = "powershell.exe -ExecutionPolicy Bypass -File `"$continuationPath`""
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\RunOnce" `
-Name "ContinuumBootstrap" `
-Value $runOnceCmd `
-PropertyType String `
-Force | Out-Null
exit 0
}