-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_windows.ps1
More file actions
50 lines (37 loc) · 1.41 KB
/
install_windows.ps1
File metadata and controls
50 lines (37 loc) · 1.41 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
$ErrorActionPreference = "Stop"
Write-Host "Installing sucata..."
$hasExpandArchive = Get-Command Expand-Archive -ErrorAction SilentlyContinue
$has7zip = Get-Command 7z -ErrorAction SilentlyContinue
if (-not $hasExpandArchive -and -not $has7zip) {
Write-Error "Needs Expand-Archive (PowerShell) or 7z to install Sucata"
exit 1
}
$TARGET = "sucata-win-amd64"
$SUCATA_VERSION = "0.1.2"
$SUCATA_NAME = "sucata.exe"
$SUCATA_URL = "https://github.com/gumpdev/sucata/releases/download/$SUCATA_VERSION/$TARGET.zip"
$SUCATA_DIR = Join-Path $HOME "sucata"
$TEMP_ZIP = Join-Path $SUCATA_DIR "temp.zip"
$BIN_PATH = Join-Path $SUCATA_DIR $SUCATA_NAME
New-Item -ItemType Directory -Force -Path $SUCATA_DIR | Out-Null
Write-Host "Downloading $SUCATA_URL"
Invoke-WebRequest -Uri $SUCATA_URL -OutFile $TEMP_ZIP -UseBasicParsing
if ($hasExpandArchive) {
Expand-Archive -Path $TEMP_ZIP -DestinationPath $SUCATA_DIR -Force
} else {
7z x $TEMP_ZIP "-o$SUCATA_DIR" -y | Out-Null
}
Write-Host "Sucata installed at $BIN_PATH"
$CURRENT_PATH = [Environment]::GetEnvironmentVariable("PATH", "User")
if ($CURRENT_PATH -notlike "*$SUCATA_DIR*") {
[Environment]::SetEnvironmentVariable(
"PATH",
"$SUCATA_DIR;$CURRENT_PATH",
"User"
)
Write-Host "Added $SUCATA_DIR to PATH"
} else {
Write-Host "PATH already contains $SUCATA_DIR"
}
Remove-Item $TEMP_ZIP
Write-Host "Done! Restart your terminal to use sucata."