-
Notifications
You must be signed in to change notification settings - Fork 471
Expand file tree
/
Copy pathinstall.ps1
More file actions
686 lines (560 loc) · 23.2 KB
/
Copy pathinstall.ps1
File metadata and controls
686 lines (560 loc) · 23.2 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
# Copyright (C) 2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
<#
.SYNOPSIS
Install Intel Geti application and its dependencies on Windows.
.DESCRIPTION
This script installs the Intel Geti application, including uv (Python package manager),
Node.js/npm, and builds both the backend and frontend.
.PARAMETER Verbose
Show detailed output from all commands.
.PARAMETER Yes
Assume yes to all prompts (non-interactive mode).
.PARAMETER WorkDir
Set the working directory (default: .\geti).
.EXAMPLE
.\install.ps1
.\install.ps1 -Verbose -Yes
.\install.ps1 -WorkDir "C:\my\custom\path"
#>
[CmdletBinding()]
param(
[Alias("y")]
[switch]$Yes,
[Alias("w")]
[string]$WorkDir = "$(Get-Location)\geti"
)
$ErrorActionPreference = "Stop"
$GIT_URL = "https://github.com/open-edge-platform/geti.git"
$GIT_BRANCH = "nightly-2026.06.19"
$BUILD_TOOLS_DIR = Join-Path $WorkDir ".build"
$UV_DIR = Join-Path $BUILD_TOOLS_DIR "uv"
$NVM_DIR = Join-Path $BUILD_TOOLS_DIR "nvm"
$LOG_FILE = Join-Path $BUILD_TOOLS_DIR ".install.log"
$script:NPM_BIN = ""
function Write-Step {
param([string]$Message)
Write-Host $Message -ForegroundColor Cyan
}
function Write-ErrorMessage {
param([string]$Message)
Write-Host "ERROR: $Message" -ForegroundColor Red
}
function Confirm-Prompt {
param([string]$Prompt)
if ($Yes) { return $true }
$response = Read-Host "$Prompt [Y/n]"
if ($response -match "^n(o)?$") { return $false }
return $true
}
function Invoke-Cmd {
param(
[string]$Command,
[string[]]$Arguments
)
# Temporarily allow stderr output without terminating (tools like npm/git
# write warnings to stderr even on success).
$prevEAP = $ErrorActionPreference
$ErrorActionPreference = "Continue"
try {
if ($VerbosePreference -eq "Continue") {
& $Command @Arguments 2>&1 | ForEach-Object {
if ($_ -is [System.Management.Automation.ErrorRecord]) {
Write-Host $_.ToString() -ForegroundColor Yellow
} else {
Write-Host $_
}
}
} else {
& $Command @Arguments *>> $LOG_FILE
}
} finally {
$ErrorActionPreference = $prevEAP
}
if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
throw "Command '$Command $($Arguments -join ' ')' failed with exit code $LASTEXITCODE"
}
}
function Invoke-CmdSpinner {
# Run a long command quietly (output to the log file) while showing an
# animated spinner, so the step never looks frozen. In verbose mode the
# full output is streamed instead.
param(
[string]$Command,
[string[]]$Arguments,
[string]$Activity = "Working"
)
if ($VerbosePreference -eq "Continue") {
Write-Host "$Activity..."
Invoke-Cmd -Command $Command -Arguments $Arguments
return
}
$stdoutTmp = [System.IO.Path]::GetTempFileName()
$stderrTmp = [System.IO.Path]::GetTempFileName()
try {
$proc = Start-Process -FilePath $Command -ArgumentList $Arguments `
-NoNewWindow -PassThru `
-RedirectStandardOutput $stdoutTmp -RedirectStandardError $stderrTmp
# Touching .Handle caches the process handle so .ExitCode is reliably
# populated after exit. Without this, Start-Process returns $null for
# .ExitCode when launching .cmd/.bat files (e.g. npm.cmd), which would
# be misread as a failure.
$null = $proc.Handle
$spinner = '|', '/', '-', '\'
$i = 0
while (-not $proc.HasExited) {
Write-Host -NoNewline ("`r{0}... {1}" -f $Activity, $spinner[$i % 4])
Start-Sleep -Milliseconds 200
$i++
}
$proc.WaitForExit()
$exitCode = $proc.ExitCode
# Append captured output to the log file for troubleshooting.
Get-Content -LiteralPath $stdoutTmp -ErrorAction SilentlyContinue | Add-Content -LiteralPath $LOG_FILE
Get-Content -LiteralPath $stderrTmp -ErrorAction SilentlyContinue | Add-Content -LiteralPath $LOG_FILE
if ($exitCode -ne 0) {
Write-Host ("`r{0}... failed " -f $Activity) -ForegroundColor Red
throw "Command '$Command $($Arguments -join ' ')' failed with exit code $exitCode"
}
Write-Host ("`r{0}... done " -f $Activity) -ForegroundColor Green
} finally {
Remove-Item -LiteralPath $stdoutTmp, $stderrTmp -ErrorAction SilentlyContinue
}
}
function Get-RequiredUvVersion {
$pyprojectPath = Join-Path $WorkDir "application\backend\pyproject.toml"
$content = Get-Content $pyprojectPath -Raw
if ($content -match '\[tool\.uv\][\s\S]*?required-version\s*=\s*"[^0-9]*([0-9]+\.[0-9]+\.[0-9]+)') {
return $Matches[1]
}
throw "Could not parse uv version from pyproject.toml"
}
function Get-RequiredNodeVersion {
$packageJsonPath = Join-Path $WorkDir "application\ui\package.json"
$json = Get-Content $packageJsonPath -Raw | ConvertFrom-Json
$nodeConstraint = $json.engines.node
if ($nodeConstraint -match '>=v?([0-9]+\.[0-9]+\.[0-9]+)') {
return $Matches[1]
}
throw "Could not parse node version from package.json"
}
function Get-RequiredNpmVersion {
$packageJsonPath = Join-Path $WorkDir "application\ui\package.json"
$json = Get-Content $packageJsonPath -Raw | ConvertFrom-Json
$npmConstraint = $json.engines.npm
if ($npmConstraint -match '>=([0-9]+\.[0-9]+\.[0-9]+)') {
return $Matches[1]
}
throw "Could not parse npm version from package.json"
}
function Install-Uv {
$uvVersion = Get-RequiredUvVersion
$uvExe = Join-Path $UV_DIR "uv.exe"
if (Test-Path $uvExe) {
$installedVersion = & $uvExe --version | ForEach-Object { ($_ -split ' ')[1] }
if ($installedVersion -eq $uvVersion) {
Write-Step "uv $uvVersion found in $UV_DIR"
return
} else {
Write-Step "uv version mismatch: installed=$installedVersion, required=$uvVersion. Reinstalling..."
}
}
Write-Step "Installing uv $uvVersion to: $UV_DIR"
if (-not (Confirm-Prompt "Would you like to install uv now?")) {
throw "uv installation skipped. Cannot continue without uv."
}
if (-not (Test-Path $UV_DIR)) {
New-Item -ItemType Directory -Path $UV_DIR -Force | Out-Null
}
$installerUrl = "https://github.com/astral-sh/uv/releases/download/$uvVersion/uv-installer.ps1"
$env:UV_INSTALL_DIR = $UV_DIR
Invoke-CmdSpinner -Command "powershell" `
-Arguments @("-ExecutionPolicy", "Bypass", "-Command", "irm '$installerUrl' | iex") `
-Activity "Downloading and installing uv $uvVersion"
Remove-Item Env:\UV_INSTALL_DIR -ErrorAction SilentlyContinue
if (-not (Test-Path $uvExe)) {
throw "uv installation failed. Expected binary at $uvExe."
}
Write-Step "uv installation complete."
}
function Install-Nvm {
$nvmExe = Join-Path $NVM_DIR "nvm.exe"
if (Test-Path $nvmExe) {
Write-Step "nvm found in $NVM_DIR."
return
}
Write-Step "Installing nvm-windows to: $NVM_DIR"
if (-not (Confirm-Prompt "Would you like to install nvm-windows now?")) {
throw "nvm installation skipped. Cannot continue without nvm."
}
if (-not (Test-Path $NVM_DIR)) {
New-Item -ItemType Directory -Path $NVM_DIR -Force | Out-Null
}
# Download nvm-windows noinstall zip
$nvmVersion = "1.2.2"
$nvmZipUrl = "https://github.com/coreybutler/nvm-windows/releases/download/$nvmVersion/nvm-noinstall.zip"
$nvmZipPath = Join-Path $BUILD_TOOLS_DIR "nvm-noinstall.zip"
Write-Host "Downloading nvm-windows $nvmVersion..."
$iwrParams = @{ Uri = $nvmZipUrl; OutFile = $nvmZipPath }
# -UseBasicParsing is required in Windows PowerShell 5.1 to avoid IE engine dependency.
# In PowerShell 7+ basic parsing is the default and the parameter is accepted but ignored.
if ($PSVersionTable.PSVersion.Major -le 5) {
$iwrParams["UseBasicParsing"] = $true
}
Invoke-WebRequest @iwrParams
Expand-Archive -Path $nvmZipPath -DestinationPath $NVM_DIR -Force
Remove-Item $nvmZipPath -Force
# Configure nvm settings
$nodeDir = Join-Path $NVM_DIR "nodejs"
$settingsContent = @"
root: $NVM_DIR
path: $nodeDir
"@
Set-Content -Path (Join-Path $NVM_DIR "settings.txt") -Value $settingsContent -Encoding ASCII
Write-Step "nvm-windows installation complete."
}
function Install-Npm {
$requiredNodeVersion = Get-RequiredNodeVersion
$requiredNpmVersion = Get-RequiredNpmVersion
$nvmExe = Join-Path $NVM_DIR "nvm.exe"
$nodeDir = Join-Path $NVM_DIR "nodejs"
$nodeVersionDir = Join-Path $NVM_DIR "v$requiredNodeVersion"
# Check if the required node version is already installed
$nodeBin = Join-Path $nodeVersionDir "node.exe"
$npmBin = Join-Path $nodeVersionDir "npm.cmd"
if (Test-Path $nodeBin) {
if (-not (Test-Path $npmBin)) {
throw "node.exe found at $nodeBin but npm.cmd is missing at $npmBin. Remove $nodeVersionDir and re-run the installer."
}
$script:NPM_BIN = $npmBin
$env:PATH = "$nodeVersionDir;$env:PATH"
$installedNpmVersion = & $npmBin --version 2>$null
if ($installedNpmVersion -and ([version]$installedNpmVersion -ge [version]$requiredNpmVersion)) {
Write-Step "node $requiredNodeVersion and npm $installedNpmVersion found."
return
}
Write-Step "npm version too old: installed=$installedNpmVersion, required>=$requiredNpmVersion. Upgrading..."
Invoke-Cmd -Command $npmBin -Arguments @("install", "-g", "npm@$requiredNpmVersion")
return
}
Write-Step "Required node $requiredNodeVersion not found. Installing..."
if (-not (Confirm-Prompt "Would you like to install node/npm now?")) {
throw "node/npm installation skipped. Cannot continue without node/npm."
}
# Set NVM_HOME for nvm.exe to work properly
$env:NVM_HOME = $NVM_DIR
$env:NVM_SYMLINK = $nodeDir
# Install node (nvm install does not require elevation)
Invoke-CmdSpinner -Command $nvmExe -Arguments @("install", $requiredNodeVersion) `
-Activity "Downloading and installing node $requiredNodeVersion"
# Skip "nvm use" as it requires admin elevation to create a symlink.
# Instead, we reference binaries directly from the version-specific directory
# and prepend to PATH so node/npm can find each other.
$env:PATH = "$nodeVersionDir;$env:PATH"
$script:NPM_BIN = $npmBin
if (-not (Test-Path $npmBin)) {
throw "node installation succeeded but npm.cmd not found at $npmBin. Installation may be corrupt."
}
$installedNpmVersion = & $npmBin --version 2>$null
if ($installedNpmVersion -and ([version]$installedNpmVersion -lt [version]$requiredNpmVersion)) {
Invoke-Cmd -Command $npmBin -Arguments @("install", "-g", "npm@$requiredNpmVersion")
}
Write-Step "node/npm installation complete."
}
function Find-NvidiaGpus {
$gpuCount = 0
# Try nvidia-smi
$nvidiaSmi = Get-Command nvidia-smi -ErrorAction SilentlyContinue
if ($nvidiaSmi) {
try {
$gpus = & nvidia-smi --query-gpu=name --format=csv,noheader 2>$null
if ($gpus) {
$gpuCount = ($gpus | Measure-Object -Line).Lines
if ($gpuCount -gt 0) {
Write-Step "Detected $gpuCount NVIDIA GPU(s) via nvidia-smi:"
& nvidia-smi --query-gpu=index,name,memory.total --format=csv,noheader
return $true
}
}
} catch {}
}
# Try WMI/CIM
try {
$gpus = Get-CimInstance -ClassName Win32_VideoController | Where-Object { $_.Name -match "NVIDIA" }
if ($gpus) {
$gpuCount = @($gpus).Count
Write-Step "Detected $gpuCount NVIDIA GPU(s):"
$gpus | ForEach-Object { Write-Host " $($_.Name)" }
return $true
}
} catch {}
Write-Host "No NVIDIA GPUs detected."
return $false
}
function Find-IntelGpus {
# Try WMI/CIM
try {
$gpus = Get-CimInstance -ClassName Win32_VideoController | Where-Object { $_.Name -match "Intel" -and $_.Name -match "Arc" }
if ($gpus) {
$gpuCount = @($gpus).Count
Write-Step "Detected $gpuCount Intel GPU(s):"
$gpus | ForEach-Object { Write-Host " $($_.Name)" }
return $true
}
} catch {}
Write-Host "No Intel GPUs detected."
return $false
}
function Test-PreflightChecks {
if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
throw "git is not installed. Please install git and try again."
}
}
function Invoke-EnsureSourceCode {
# Git commands write informational messages to stderr which PowerShell
# treats as terminating errors under $ErrorActionPreference = "Stop".
# We temporarily switch to Continue for all git invocations here.
$prevEAP = $ErrorActionPreference
$ErrorActionPreference = "Continue"
try {
if (-not (Test-Path $WorkDir)) {
Write-Step "Cloning Intel Geti repository from $GIT_URL..."
Write-Host "This can take several minutes depending on your connection." -ForegroundColor DarkGray
# Let git print its native progress meter so the clone never looks frozen.
& git -c advice.detachedHead=false clone --progress --branch $GIT_BRANCH $GIT_URL $WorkDir
if ($LASTEXITCODE -ne 0) { throw "git clone failed (exit code $LASTEXITCODE)" }
} else {
Write-Step "Work directory $WorkDir already exists, skipping clone."
$remoteUrl = (& git -C $WorkDir remote get-url origin 2>$null)
if ($remoteUrl -ne $GIT_URL) {
throw "$WorkDir remote origin is '$remoteUrl', expected '$GIT_URL'. Remove $WorkDir and re-run the installer."
}
$currentSha = (& git -C $WorkDir rev-parse HEAD 2>$null)
& git -C $WorkDir fetch origin "refs/tags/${GIT_BRANCH}:refs/tags/${GIT_BRANCH}" --force 2>&1 | Out-Null
if ($LASTEXITCODE -ne 0) {
# Fallback: try fetching as a branch
& git -C $WorkDir fetch origin $GIT_BRANCH --tags 2>&1 | Out-Null
}
# Resolve the expected SHA: try as tag first, then as remote branch
$expectedSha = (& git -C $WorkDir rev-parse "refs/tags/$GIT_BRANCH" 2>$null) | Select-Object -First 1
if (-not $expectedSha -or $expectedSha -notmatch '^[0-9a-f]{40}$') {
$expectedSha = (& git -C $WorkDir rev-parse "origin/$GIT_BRANCH" 2>$null) | Select-Object -First 1
}
if (-not $expectedSha -or $expectedSha -notmatch '^[0-9a-f]{40}$') {
throw "Could not resolve ref '$GIT_BRANCH'. Ensure it exists on the remote."
}
if ($currentSha -ne $expectedSha) {
Write-Step "Updating to $GIT_BRANCH..."
& git -c advice.detachedHead=false -C $WorkDir checkout --force $GIT_BRANCH 2>&1 | Out-Null
if ($LASTEXITCODE -ne 0) { throw "git checkout failed (exit code $LASTEXITCODE)" }
}
}
} finally {
$ErrorActionPreference = $prevEAP
}
}
function Install-BuildTools {
Install-Uv
Install-Nvm
Install-Npm
}
function Find-Hardware {
$script:HAS_NVIDIA_GPU = $false
$script:HAS_INTEL_GPU = $false
if (Find-NvidiaGpus) {
$script:HAS_NVIDIA_GPU = $true
}
if (Find-IntelGpus) {
$script:HAS_INTEL_GPU = $true
}
if ($script:HAS_NVIDIA_GPU) {
$script:ACCELERATOR = "cuda"
} elseif ($script:HAS_INTEL_GPU) {
$script:ACCELERATOR = "xpu"
} else {
$script:ACCELERATOR = "cpu"
}
$env:ACCELERATOR = $script:ACCELERATOR
}
function Build-Backend {
Write-Step "Building Python environment using accelerator: $($script:ACCELERATOR)"
Write-Host "This downloads PyTorch, OpenVINO and other large packages and can take several minutes." -ForegroundColor DarkGray
$backendDir = Join-Path $WorkDir "application\backend"
Push-Location $backendDir
try {
$uvExe = Join-Path $UV_DIR "uv.exe"
# uv shows its own progress meter; do not suppress it so the user gets feedback.
& $uvExe sync --frozen --extra mqtt --extra $script:ACCELERATOR
if ($LASTEXITCODE -ne 0) { throw "uv sync failed" }
Write-Step "Generating OpenAPI specification..."
$prevPythonPath = $env:PYTHONPATH
$env:PYTHONPATH = "."
try {
& $uvExe run --no-sync app/cli.py gen-api --target-path openapi.json
if ($LASTEXITCODE -ne 0) { throw "OpenAPI generation failed" }
} finally {
$env:PYTHONPATH = $prevPythonPath
}
$uiApiDir = Join-Path $WorkDir "application\ui\src\api"
Copy-Item -Path "openapi.json" -Destination (Join-Path $uiApiDir "openapi-spec.json") -Force
} finally {
Pop-Location
}
}
function Build-Frontend {
$uiDir = Join-Path $WorkDir "application\ui"
Push-Location $uiDir
try {
$env:npm_config_yes = "true"
# The 'preinstall' hook clones geti_v2 via `npx tiged`, which contains
# files with very long paths that exceed the Windows MAX_PATH (260) limit
# and fail checkout with "Filename too long". Enable git long-path support
# for the child git processes without modifying the user's global config
# (GIT_CONFIG_* env vars are inherited by tiged's internal `git clone`).
$env:GIT_CONFIG_COUNT = "1"
$env:GIT_CONFIG_KEY_0 = "core.longpaths"
$env:GIT_CONFIG_VALUE_0 = "true"
# --foreground-scripts surfaces lifecycle-script errors (e.g. the
# 'preinstall' UI-package clone) in the log instead of a generic exit code.
Invoke-CmdSpinner -Command $script:NPM_BIN `
-Arguments @("ci", "--foreground-scripts") `
-Activity "Installing UI dependencies (this may take several minutes)"
Remove-Item Env:\GIT_CONFIG_COUNT, Env:\GIT_CONFIG_KEY_0, Env:\GIT_CONFIG_VALUE_0 -ErrorAction SilentlyContinue
Invoke-CmdSpinner -Command $script:NPM_BIN `
-Arguments @("run", "build:api") `
-Activity "Building API client"
$env:ASSET_PREFIX = "/html"
Invoke-CmdSpinner -Command $script:NPM_BIN `
-Arguments @("run", "build") `
-Activity "Building UI (this may take several minutes)"
Remove-Item Env:\ASSET_PREFIX -ErrorAction SilentlyContinue
} finally {
Pop-Location
}
}
function Deploy-Frontend {
$htmlDir = Join-Path $WorkDir "application\backend\html"
Write-Step "Copying built UI to backend html directory..."
if (Test-Path $htmlDir) {
Remove-Item -Path $htmlDir -Recurse -Force
}
New-Item -ItemType Directory -Path $htmlDir -Force | Out-Null
$distDir = Join-Path $WorkDir "application\ui\dist\*"
Copy-Item -Path $distDir -Destination $htmlDir -Recurse -Force
}
function Register-ShellCommand {
$uvExe = Join-Path $UV_DIR "uv.exe"
$backendDir = Join-Path $WorkDir "application\backend"
# Create a geti.cmd batch file in the work directory
$cmdPath = Join-Path $WorkDir "geti.cmd"
$cmdContent = @"
@echo off
pushd "$backendDir"
set STATIC_FILES_DIR=html
"$uvExe" run app/main.py %*
popd
"@
Set-Content -Path $cmdPath -Value $cmdContent -Encoding ASCII
# Create a geti.ps1 PowerShell wrapper
$ps1Path = Join-Path $WorkDir "geti.ps1"
$ps1Content = @"
# Intel Geti launcher
param([Parameter(ValueFromRemainingArguments=`$true)]`$Args)
Push-Location "$backendDir"
try {
`$env:STATIC_FILES_DIR = "html"
& "$uvExe" run app/main.py @Args
} finally {
Pop-Location
}
"@
Set-Content -Path $ps1Path -Value $ps1Content
# Add to PowerShell profile (opt-in: requires confirmation or -Yes)
if (-not (Confirm-Prompt "Would you like to add the 'geti' function to your PowerShell profile?")) {
Write-Host "Profile modification skipped."
Write-Host "You can run geti manually via: $ps1Path"
Write-Host "Or via batch file: $cmdPath"
return
}
$profileDir = Split-Path $PROFILE -Parent
if (-not (Test-Path $profileDir)) {
New-Item -ItemType Directory -Path $profileDir -Force | Out-Null
}
if (-not (Test-Path $PROFILE)) {
New-Item -ItemType File -Path $PROFILE -Force | Out-Null
}
$beginMarker = "# BEGIN Intel Geti"
$endMarker = "# END Intel Geti"
$profileContent = Get-Content $PROFILE -Raw -ErrorAction SilentlyContinue
# Remove old marker block if present
if ($profileContent -and $profileContent -match [regex]::Escape($beginMarker)) {
$profileContent = $profileContent -replace "(?s)\r?\n?$([regex]::Escape($beginMarker)).*?$([regex]::Escape($endMarker))\r?\n?", ""
Set-Content -Path $PROFILE -Value $profileContent -NoNewline -Encoding UTF8
}
$functionBlock = @"
$beginMarker
function geti { Push-Location "$backendDir"; try { `$env:STATIC_FILES_DIR = "html"; & "$uvExe" run app/main.py @args } finally { Pop-Location } }
$endMarker
"@
Add-Content -Path $PROFILE -Value $functionBlock -Encoding UTF8
Write-Step "Function 'geti' written to $PROFILE"
Write-Host "Run '. `$PROFILE' to activate it in the current session."
Write-Host "Example: `$env:HOST='0.0.0.0'; `$env:PORT='8080'; geti"
Write-Host ""
Write-Host "Batch file also available at: $cmdPath"
}
# ─── Main ────────────────────────────────────────────────────────────────────
function Main {
Write-Host ""
Write-Host "Intel Geti Installer (Windows/PowerShell)" -ForegroundColor Green
Write-Host "==========================================" -ForegroundColor Green
Write-Host ""
Test-PreflightChecks
Invoke-EnsureSourceCode
# Initialize log file and build tools directory
if (-not (Test-Path $BUILD_TOOLS_DIR)) {
New-Item -ItemType Directory -Path $BUILD_TOOLS_DIR -Force | Out-Null
}
"" | Set-Content -Path $LOG_FILE
Install-BuildTools
Find-Hardware
Build-Backend
Build-Frontend
Deploy-Frontend
Register-ShellCommand
Start-App
}
function Start-App {
Write-Host ""
Write-Step "Installation complete! Starting Intel Geti..."
$uvExe = Join-Path $UV_DIR "uv.exe"
$backendDir = Join-Path $WorkDir "application\backend"
# Resolve the URL the user should open. The server binds to 0.0.0.0 by
# default, which is not a valid address to open in a browser, so use
# localhost. Honour PORT/HOST overrides if the user set them.
$port = if ($env:PORT) { $env:PORT } else { "7860" }
$browserHost = if ($env:HOST -and $env:HOST -ne "0.0.0.0") { $env:HOST } else { "localhost" }
$url = "http://${browserHost}:${port}"
Write-Host ""
Write-Host "Geti will be available at: " -NoNewline
Write-Host $url -ForegroundColor Cyan
Write-Host ""
Push-Location $backendDir
try {
$env:STATIC_FILES_DIR = "html"
& $uvExe run app/main.py
} finally {
Pop-Location
}
}
try {
Main
} catch {
Write-Host ""
Write-ErrorMessage "Installation failed: $_"
if (Test-Path $LOG_FILE) {
Write-Host "Check $LOG_FILE for details."
}
Write-Host "Re-run with -Verbose for more details."
exit 1
}