mirror of
https://github.com/henrygd/beszel.git
synced 2026-03-22 05:36:15 +01:00
add InstallMethod parameter to Windows install script
Allows users to explicitly choose Scoop or WinGet for installation instead of relying on auto-detection. Useful when both package managers are installed but the user prefers one over the other.
This commit is contained in:
@@ -7,13 +7,15 @@ param (
|
|||||||
[int]$Port = 45876,
|
[int]$Port = 45876,
|
||||||
[string]$AgentPath = "",
|
[string]$AgentPath = "",
|
||||||
[string]$NSSMPath = "",
|
[string]$NSSMPath = "",
|
||||||
[switch]$ConfigureFirewall
|
[switch]$ConfigureFirewall,
|
||||||
|
[ValidateSet("Auto", "Scoop", "WinGet")]
|
||||||
|
[string]$InstallMethod = "Auto"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check if required parameters are provided
|
# Check if required parameters are provided
|
||||||
if ([string]::IsNullOrWhiteSpace($Key)) {
|
if ([string]::IsNullOrWhiteSpace($Key)) {
|
||||||
Write-Host "ERROR: SSH Key is required." -ForegroundColor Red
|
Write-Host "ERROR: SSH Key is required." -ForegroundColor Red
|
||||||
Write-Host "Usage: .\install-agent.ps1 -Key 'your-ssh-key-here' [-Token 'your-token-here'] [-Url 'your-hub-url-here'] [-Port port-number] [-ConfigureFirewall]" -ForegroundColor Yellow
|
Write-Host "Usage: .\install-agent.ps1 -Key 'your-ssh-key-here' [-Token 'your-token-here'] [-Url 'your-hub-url-here'] [-Port port-number] [-InstallMethod Auto|Scoop|WinGet] [-ConfigureFirewall]" -ForegroundColor Yellow
|
||||||
Write-Host "Note: Token and Url are optional for backwards compatibility with older hub versions." -ForegroundColor Yellow
|
Write-Host "Note: Token and Url are optional for backwards compatibility with older hub versions." -ForegroundColor Yellow
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
@@ -486,18 +488,34 @@ try {
|
|||||||
Write-Host "2. Install WinGet and run this script again" -ForegroundColor Yellow
|
Write-Host "2. Install WinGet and run this script again" -ForegroundColor Yellow
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Test-CommandExists "scoop") {
|
if ($InstallMethod -eq "Scoop") {
|
||||||
|
if (-not (Test-CommandExists "scoop")) {
|
||||||
|
throw "InstallMethod is set to Scoop, but Scoop is not available in PATH."
|
||||||
|
}
|
||||||
Write-Host "Using Scoop for installation..."
|
Write-Host "Using Scoop for installation..."
|
||||||
$AgentPath = Install-WithScoop -Key $Key -Port $Port
|
$AgentPath = Install-WithScoop -Key $Key -Port $Port
|
||||||
}
|
}
|
||||||
elseif (Test-CommandExists "winget") {
|
elseif ($InstallMethod -eq "WinGet") {
|
||||||
|
if (-not (Test-CommandExists "winget")) {
|
||||||
|
throw "InstallMethod is set to WinGet, but WinGet is not available in PATH."
|
||||||
|
}
|
||||||
Write-Host "Using WinGet for installation..."
|
Write-Host "Using WinGet for installation..."
|
||||||
$AgentPath = Install-WithWinGet -Key $Key -Port $Port
|
$AgentPath = Install-WithWinGet -Key $Key -Port $Port
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Write-Host "Neither Scoop nor WinGet is installed. Installing Scoop..."
|
if (Test-CommandExists "scoop") {
|
||||||
$AgentPath = Install-WithScoop -Key $Key -Port $Port
|
Write-Host "Using Scoop for installation..."
|
||||||
|
$AgentPath = Install-WithScoop -Key $Key -Port $Port
|
||||||
|
}
|
||||||
|
elseif (Test-CommandExists "winget") {
|
||||||
|
Write-Host "Using WinGet for installation..."
|
||||||
|
$AgentPath = Install-WithWinGet -Key $Key -Port $Port
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Host "Neither Scoop nor WinGet is installed. Installing Scoop..."
|
||||||
|
$AgentPath = Install-WithScoop -Key $Key -Port $Port
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -561,7 +579,8 @@ try {
|
|||||||
"-Token", "`"$Token`"",
|
"-Token", "`"$Token`"",
|
||||||
"-Url", "`"$Url`"",
|
"-Url", "`"$Url`"",
|
||||||
"-Port", $Port,
|
"-Port", $Port,
|
||||||
"-AgentPath", "`"$AgentPath`""
|
"-AgentPath", "`"$AgentPath`"",
|
||||||
|
"-InstallMethod", $InstallMethod
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add NSSMPath if we found it
|
# Add NSSMPath if we found it
|
||||||
|
|||||||
Reference in New Issue
Block a user