-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.ps1
More file actions
64 lines (53 loc) · 2.26 KB
/
install.ps1
File metadata and controls
64 lines (53 loc) · 2.26 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
# Webex CLI installer for Windows
# Usage: irm https://raw.githubusercontent.com/Cloverhound/webex-cli/main/install.ps1 | iex
$ErrorActionPreference = "Stop"
$Repo = "Cloverhound/webex-cli"
$Binary = "webex.exe"
$InstallDir = "$env:LOCALAPPDATA\webex-cli"
# Detect architecture
$Arch = if ([Environment]::Is64BitOperatingSystem) {
if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") { "arm64" } else { "amd64" }
} else {
Write-Error "Unsupported: 32-bit Windows is not supported"
return
}
# Get latest version
Write-Host "Fetching latest release..."
$Release = Invoke-RestMethod "https://api.github.com/repos/$Repo/releases/latest"
$Version = $Release.tag_name -replace '^v', ''
if (-not $Version) {
Write-Error "Could not determine latest version"
return
}
Write-Host "Latest version: v$Version"
# Download
$ZipName = "webex-cli_${Version}_windows_${Arch}.zip"
$Url = "https://github.com/$Repo/releases/download/v$Version/$ZipName"
$TmpDir = New-Item -ItemType Directory -Path (Join-Path $env:TEMP "webex-cli-install-$(Get-Random)")
try {
Write-Host "Downloading $Url..."
Invoke-WebRequest -Uri $Url -OutFile (Join-Path $TmpDir $ZipName)
# Extract
Expand-Archive -Path (Join-Path $TmpDir $ZipName) -DestinationPath $TmpDir -Force
# Install
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
Move-Item -Path (Join-Path $TmpDir $Binary) -Destination (Join-Path $InstallDir $Binary) -Force
# Add to user PATH if not already there
$UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($UserPath -notlike "*$InstallDir*") {
[Environment]::SetEnvironmentVariable("Path", "$InstallDir;$UserPath", "User")
$env:Path = "$InstallDir;$env:Path"
Write-Host "Added $InstallDir to your PATH."
}
Write-Host ""
Write-Host "Installed webex v$Version to $InstallDir\$Binary"
Write-Host ""
Write-Host "NOTE: Restart your terminal for PATH changes to take effect."
Write-Host ""
Write-Host "Get started:"
Write-Host " webex config set client-id <your-client-id> # if not using built-in defaults"
Write-Host " webex config set client-secret <your-client-secret>"
Write-Host " webex login"
} finally {
Remove-Item -Recurse -Force $TmpDir -ErrorAction SilentlyContinue
}