-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
107 lines (90 loc) · 3.78 KB
/
Copy pathinstall.ps1
File metadata and controls
107 lines (90 loc) · 3.78 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#Requires -Version 5.1
# =============================================================================
# FlashAudit Windows Installer
# Usage: irm https://raw.githubusercontent.com/Ruddxxy/Flash-Audit-Core/main/install.ps1 | iex
# =============================================================================
param(
[string]$Version = "latest",
[string]$InstallDir = "$env:LOCALAPPDATA\FlashAudit\bin"
)
$ErrorActionPreference = "Stop"
$Repo = "Ruddxxy/Flash-Audit-Core"
function Write-Info { param($Message) Write-Host "[INFO] $Message" -ForegroundColor Green }
function Write-Warn { param($Message) Write-Host "[WARN] $Message" -ForegroundColor Yellow }
function Write-Err { param($Message) Write-Host "[ERROR] $Message" -ForegroundColor Red; exit 1 }
Write-Host ""
Write-Host " _____ _ _ _ _ _ _ " -ForegroundColor Cyan
Write-Host " | ___| | __ _ ___| |__ / \ _ _ __| (_) |_ " -ForegroundColor Cyan
Write-Host " | |_ | |/ _`` / __| '_ \/ _ \| | | |/ _`` | | __|" -ForegroundColor Cyan
Write-Host " | _| | | (_| \__ \ | | / ___ \ |_| | (_| | | |_ " -ForegroundColor Cyan
Write-Host " |_| |_|\__,_|___/_| |_\_/ \_\__,_|\__,_|_|\__|" -ForegroundColor Cyan
Write-Host ""
Write-Host " High-performance secrets scanner" -ForegroundColor White
Write-Host ""
# Get latest version if not specified
if ($Version -eq "latest") {
Write-Info "Fetching latest version..."
try {
$Release = Invoke-RestMethod "https://api.github.com/repos/$Repo/releases/latest"
$Version = $Release.tag_name -replace '^v', ''
} catch {
Write-Err "Failed to fetch latest version. Check https://github.com/$Repo/releases"
}
}
$Version = $Version -replace '^v', ''
Write-Info "Installing FlashAudit version: $Version"
# Determine architecture
$Arch = if ([Environment]::Is64BitOperatingSystem) { "x86_64" } else { "x86" }
if ($Arch -eq "x86") {
Write-Err "32-bit Windows is not supported"
}
$FileName = "flash_audit-windows-x86_64.exe"
$DownloadUrl = "https://github.com/$Repo/releases/download/v$Version/$FileName.zip"
# Create temp directory
$TempDir = Join-Path $env:TEMP "flashaudit-install-$(Get-Random)"
New-Item -ItemType Directory -Force -Path $TempDir | Out-Null
$ZipFile = Join-Path $TempDir "flashaudit.zip"
Write-Info "Downloading from: $DownloadUrl"
try {
Invoke-WebRequest -Uri $DownloadUrl -OutFile $ZipFile -UseBasicParsing
} catch {
Write-Err "Failed to download. Check if version $Version exists at https://github.com/$Repo/releases"
}
# Extract
Write-Info "Extracting..."
Expand-Archive -Path $ZipFile -DestinationPath $TempDir -Force
# Find binary
$Binary = Get-ChildItem -Path $TempDir -Recurse -Filter "*.exe" | Select-Object -First 1
if (-not $Binary) {
Write-Err "Binary not found in archive"
}
# Install
Write-Info "Installing to $InstallDir..."
New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
Copy-Item $Binary.FullName -Destination (Join-Path $InstallDir "flash_audit.exe") -Force
# Add to PATH if not already there
$UserPath = [Environment]::GetEnvironmentVariable("PATH", "User")
if ($UserPath -notlike "*$InstallDir*") {
Write-Info "Adding $InstallDir to PATH..."
[Environment]::SetEnvironmentVariable("PATH", "$UserPath;$InstallDir", "User")
$env:PATH = "$env:PATH;$InstallDir"
}
# Cleanup
Remove-Item -Recurse -Force $TempDir
# Verify
Write-Info "FlashAudit installed successfully!"
Write-Host ""
try {
& (Join-Path $InstallDir "flash_audit.exe") --version
} catch {
Write-Host " flash_audit v$Version"
}
Write-Host ""
Write-Info "Get started:"
Write-Host " flash_audit C:\path\to\repo"
Write-Host " flash_audit --help"
Write-Host ""
Write-Warn "Restart your terminal to use flash_audit from any directory"
Write-Host ""
Write-Host " Documentation: https://github.com/$Repo" -ForegroundColor Gray
Write-Host ""