-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathinstall.ps1
More file actions
67 lines (53 loc) · 2.44 KB
/
Copy pathinstall.ps1
File metadata and controls
67 lines (53 loc) · 2.44 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
$ErrorActionPreference = "Stop"
$REPO = "ErickJ3/faze"
$INSTALL_DIR = if ($env:FAZE_INSTALL_DIR) { $env:FAZE_INSTALL_DIR } else { "$env:LOCALAPPDATA\faze" }
function Get-LatestRelease {
$response = Invoke-RestMethod -Uri "https://api.github.com/repos/$REPO/releases/latest"
return $response.tag_name
}
function Main {
Write-Host "Detecting platform..."
$arch = $env:PROCESSOR_ARCHITECTURE
if ($arch -ne "AMD64") {
Write-Error "Unsupported architecture: $arch"
exit 1
}
$platform = "windows-x86_64"
Write-Host "Platform: $platform"
Write-Host "Getting latest release..."
$version = Get-LatestRelease
Write-Host "Latest version: $version"
$assetName = "faze-${platform}.exe"
$downloadUrl = "https://github.com/$REPO/releases/download/$version/${assetName}.zip"
Write-Host "Downloading from $downloadUrl..."
$tempDir = New-Item -ItemType Directory -Path ([System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), [System.IO.Path]::GetRandomFileName()))
$zipPath = Join-Path $tempDir "faze.zip"
try {
Invoke-WebRequest -Uri $downloadUrl -OutFile $zipPath
Write-Host "Extracting..."
Expand-Archive -Path $zipPath -DestinationPath $tempDir -Force
Write-Host "Installing to $INSTALL_DIR..."
New-Item -ItemType Directory -Force -Path $INSTALL_DIR | Out-Null
Copy-Item -Path (Join-Path $tempDir "faze.exe") -Destination (Join-Path $INSTALL_DIR "faze.exe") -Force
Write-Host ""
Write-Host "faze installed successfully to $INSTALL_DIR\faze.exe"
Write-Host ""
$currentPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($currentPath -notlike "*$INSTALL_DIR*") {
Write-Host "NOTE: $INSTALL_DIR is not in your PATH."
Write-Host "Add it by running:"
Write-Host ""
Write-Host " `$env:Path += `";$INSTALL_DIR`""
Write-Host " [Environment]::SetEnvironmentVariable('Path', `$env:Path + `";$INSTALL_DIR`", 'User')"
Write-Host ""
Write-Host "Or restart your terminal after running:"
Write-Host " [Environment]::SetEnvironmentVariable('Path', [Environment]::GetEnvironmentVariable('Path', 'User') + `";$INSTALL_DIR`", 'User')"
} else {
Write-Host "Run 'faze --help' to get started!"
}
}
finally {
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
}
}
Main