-
Notifications
You must be signed in to change notification settings - Fork 896
/
Copy pathinstall.ps1
114 lines (96 loc) · 3.89 KB
/
install.ps1
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
Write-Host "installing screenpipe..."
try {
# Get latest version
$releases = Invoke-RestMethod "https://api.github.com/repos/mediar-ai/screenpipe/releases"
$latestRelease = $releases | Where-Object { -not $_.prerelease } | Select-Object -First 1
if (-not $latestRelease) {
throw "no releases found"
}
# Find the Windows asset
$asset = $latestRelease.assets | Where-Object { $_.name -like "*-x86_64-pc-windows-msvc.zip" } | Select-Object -First 1
if (-not $asset) {
throw "no Windows release found in version $($latestRelease.tag_name)"
}
$url = $asset.browser_download_url
$installDir = "$env:USERPROFILE\screenpipe"
$tempZip = "$env:TEMP\screenpipe.zip"
# Download and extract
Write-Host "downloading latest version ($($latestRelease.tag_name)) from $url..."
Invoke-WebRequest -Uri $url -OutFile $tempZip
# Create install directory if it doesn't exist
if (!(Test-Path $installDir)) {
New-Item -ItemType Directory -Path $installDir | Out-Null
}
Write-Host "extracting..."
Expand-Archive -Path $tempZip -DestinationPath $installDir -Force
# Add to PATH if not already there
$currentPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($currentPath -notlike "*$installDir\bin*") {
[Environment]::SetEnvironmentVariable("Path", "$currentPath;$installDir\bin", "User")
$env:Path = [Environment]::GetEnvironmentVariable("Path", "User")
}
# Verify installation
$binPath = Join-Path $installDir "bin\screenpipe.exe"
if (!(Test-Path $binPath)) {
throw "screenpipe.exe not found in $binPath after installation"
}
# Cleanup
Remove-Item $tempZip -Force
# Check if bun is installed
$bunInstalled = $false
$bunVersion = ""
try {
$bunVersion = (bun --version 2>$null) -replace "[^\d\.]", ""
if ($bunVersion -as [version] -ge [version]"1.1.43") {
$bunInstalled = $true
}
}
catch {}
if ($bunInstalled) {
Write-Host "Bun is already installed and meets version requirements"
}
else {
Write-Host "Installing bun..."
powershell -c "irm bun.sh/install.ps1|iex"
}
# Install Visual Studio Redistributables to avoid any ort issues
Write-Host "Installing Visual Studio Redistributables..."
Write-Host ""
# Inform the user about the need for elevation
Write-Host "The script requires administrative privileges. You will be prompted to allow this action."
Start-Process powershell -Verb RunAs -ArgumentList @"
-NoProfile -ExecutionPolicy Bypass -Command "& {
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://vcredist.com/install.ps1'))
}"
"@
Write-Host "Installation Complete"
Write-Host ""
Write-Host "to get started:"
Write-Host "1. restart your terminal"
Write-Host "2. run: screenpipe"
Write-Host ""
Write-Host "join our discord: https://discord.gg/dU9EBuw7Uq"
Write-Host "check the docs: https://docs.screenpi.pe"
try {
$postHogData = @{
api_key = "phc_Bt8GoTBPgkCpDrbaIZzJIEYt0CrJjhBiuLaBck1clce"
event = "cli_install"
properties = @{
distinct_id = $env:COMPUTERNAME
version = $latestRelease.tag_name
os = "windows"
arch = "x86_64"
}
} | ConvertTo-Json
Invoke-RestMethod -Uri "https://eu.i.posthog.com/capture/" -Method Post -Body $postHogData -ContentType "application/json"
}
catch {
# Silently continue if tracking fails
}
}
catch {
Write-Host "installation failed: $($_.Exception.Message)" -ForegroundColor Red
exit 1
}