feat: 优化安装脚本,提前检测架构并简化 GitHub 代理显示

This commit is contained in:
Akizon77
2025-06-05 00:51:27 +08:00
parent 20b6d38321
commit 5b599f1e96

View File

@@ -31,14 +31,24 @@ if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdent
exit 1
}
# Prepare GitHub proxy display
if ($GitHubProxy -ne '') { $ProxyDisplay = $GitHubProxy } else { $ProxyDisplay = '(direct)' }
# Detect architecture early for constructing binary name
switch ($env:PROCESSOR_ARCHITECTURE) {
'AMD64' { $arch = 'amd64' }
'ARM64' { $arch = 'arm64' }
Default { Log-Error "Unsupported architecture: $env:PROCESSOR_ARCHITECTURE"; exit 1 }
}
Log-Step "Installation configuration:"
Log-Config "Service name: $ServiceName"
Log-Config "Install directory: $InstallDir"
Log-Config "GitHub proxy: $($GitHubProxy -ne '' ? $GitHubProxy : '(direct)')"
Log-Config "GitHub proxy: $ProxyDisplay"
Log-Config "Agent arguments: $($KomariArgs -join ' ')"
# Paths
$BinaryName = "komari-agent-windows-$((switch($env:PROCESSOR_ARCHITECTURE) { 'AMD64' { 'amd64' }; 'ARM64' { 'arm64' }; Default { '' } })) .exe".Trim()
$BinaryName = "komari-agent-windows-$arch.exe"
$AgentPath = Join-Path $InstallDir $BinaryName
# Uninstall previous service and binary
@@ -58,14 +68,6 @@ function Uninstall-Previous {
}
Uninstall-Previous
# Detect architecture
switch ($env:PROCESSOR_ARCHITECTURE) {
"AMD64" { $arch = "amd64" }
"ARM64" { $arch = "arm64" }
Default { Log-Error "Unsupported architecture: $env:PROCESSOR_ARCHITECTURE"; exit 1 }
}
Log-Info "Detected architecture: $arch"
# Fetch latest release version
$ApiUrl = "https://api.github.com/repos/komari-monitor/komari-agent/releases/latest"
Log-Step "Fetching latest version from GitHub API..."