-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
69 lines (56 loc) · 2.15 KB
/
install.ps1
File metadata and controls
69 lines (56 loc) · 2.15 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
#!/usr/bin/env pwsh
# Copyright 2019-2025 the Deno authors. All rights reserved. MIT license.
# Copyright 2025 OpenStatus. All rights reserved. MIT license.
# Adopted from https://github.com/denoland/deno_install
$ErrorActionPreference = 'Stop'
if ($v) {
$Version = "v${v}"
}
if ($Args.Length -eq 1) {
$Version = $Args.Get(0)
}
$OpenstatusInstall = $env:OPENSTATUS_INSTALL
$BinDir = if ($OpenstatusInstall) {
"${OpenstatusInstall}\bin"
} else {
"${Home}\.openstatus\bin"
}
$OpenstatusExe = "$BinDir\openstatus.exe"
# Detect architecture
$Arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture
$Target = switch ($Arch) {
"Arm64" { "Windows_arm64" }
"X86" { "Windows_i386" }
default { "Windows_x86_64" }
}
$Version = if (!$Version) {
curl.exe --ssl-revoke-best-effort -s "https://api.github.com/repos/openstatusHQ/cli/releases/latest" |
ConvertFrom-Json |
Select-Object -ExpandProperty tag_name
} else {
$Version
}
Write-Output "Installing openstatus ${Version} for ${Target}"
$DownloadUrl = "https://github.com/openstatusHQ/cli/releases/download/${Version}/cli_${Target}.zip"
if (!(Test-Path $BinDir)) {
New-Item $BinDir -ItemType Directory | Out-Null
}
# Download and extract the zip file
$TempDir = New-Item -ItemType Directory -Path (Join-Path $env:TEMP ([System.IO.Path]::GetRandomFileName()))
$ZipFile = Join-Path $TempDir "openstatus.zip"
try {
curl.exe --ssl-revoke-best-effort -Lo $ZipFile $DownloadUrl
Expand-Archive -Path $ZipFile -DestinationPath $TempDir -Force
Move-Item -Path (Join-Path $TempDir "openstatus.exe") -Destination $OpenstatusExe -Force
} finally {
Remove-Item -Path $TempDir -Recurse -Force -ErrorAction SilentlyContinue
}
$User = [System.EnvironmentVariableTarget]::User
$Path = [System.Environment]::GetEnvironmentVariable('Path', $User)
if (!(";${Path};".ToLower() -like "*;${BinDir};*".ToLower())) {
[System.Environment]::SetEnvironmentVariable('Path', "${Path};${BinDir}", $User)
$Env:Path += ";${BinDir}"
}
Write-Output "openstatus was installed successfully to ${OpenstatusExe}"
Write-Output "Run 'openstatus --help' to get started"
Write-Output "Stuck? Join our Discord https://openstatus.dev/discord"