-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.ps1
More file actions
47 lines (38 loc) · 1.58 KB
/
Copy pathinstall.ps1
File metadata and controls
47 lines (38 loc) · 1.58 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
# usectl CLI installer for Windows
# Usage: iwr -useb https://manager.usectl.com/releases/install.ps1 | iex
$ErrorActionPreference = 'Stop'
$Binary = "usectl.exe"
$BaseUrl = "https://manager.usectl.com/releases/latest"
$InstallDir = "$env:LOCALAPPDATA\usectl"
# Detect architecture
$Arch = if ([System.Environment]::Is64BitOperatingSystem) { "amd64" } else { "386" }
$Filename = "usectl-windows-$Arch.exe"
$Url = "$BaseUrl/$Filename"
Write-Host "==> Downloading usectl for windows/$Arch..."
Write-Host " $Url"
# Create install directory if it doesn't exist
if (-not (Test-Path $InstallDir)) {
New-Item -ItemType Directory -Path $InstallDir | Out-Null
}
# Download to temp file, then move into place
$TmpFile = [System.IO.Path]::GetTempFileName() + ".exe"
try {
Invoke-WebRequest -Uri $Url -OutFile $TmpFile -UseBasicParsing
Move-Item -Path $TmpFile -Destination "$InstallDir\$Binary" -Force
} finally {
if (Test-Path $TmpFile) { Remove-Item $TmpFile -Force -ErrorAction SilentlyContinue }
}
# Add to user PATH if not already present
$UserPath = [System.Environment]::GetEnvironmentVariable("PATH", "User")
if ($UserPath -notlike "*$InstallDir*") {
[System.Environment]::SetEnvironmentVariable("PATH", "$UserPath;$InstallDir", "User")
Write-Host "==> Added $InstallDir to your PATH"
Write-Host " Restart your terminal, or run to use immediately:"
Write-Host " `$env:PATH += ';$InstallDir'"
}
Write-Host ""
Write-Host "==> usectl installed successfully!"
Write-Host ""
Write-Host "Get started:"
Write-Host " usectl login"
Write-Host " usectl --help"