mirror of
https://github.com/fankes/beszel.git
synced 2025-10-19 09:49:28 +08:00
Windows agent install script improvements
- Remove unneeded set-executionpolicy (in parent command) - Wait before checking status - Use direct binary path instead of shim - Log to one file Co-authored-by: vmhomelab <info@vmhomelab.de>
This commit is contained in:
@@ -28,7 +28,6 @@ if (-not $Elevated) {
|
|||||||
Write-Host "Scoop is already installed."
|
Write-Host "Scoop is already installed."
|
||||||
} else {
|
} else {
|
||||||
Write-Host "Installing Scoop..."
|
Write-Host "Installing Scoop..."
|
||||||
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
|
|
||||||
Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression
|
Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression
|
||||||
|
|
||||||
if (-not (Get-Command scoop -ErrorAction SilentlyContinue)) {
|
if (-not (Get-Command scoop -ErrorAction SilentlyContinue)) {
|
||||||
@@ -93,7 +92,7 @@ if (-not $Elevated) {
|
|||||||
|
|
||||||
# Admin tasks - service installation and firewall rules
|
# Admin tasks - service installation and firewall rules
|
||||||
try {
|
try {
|
||||||
$agentPath = (Get-Command beszel-agent -ErrorAction SilentlyContinue).Path
|
$agentPath = Join-Path -Path $(scoop prefix beszel-agent) -ChildPath "beszel-agent.exe"
|
||||||
if (-not $agentPath) {
|
if (-not $agentPath) {
|
||||||
throw "Could not find beszel-agent executable. Make sure it was properly installed."
|
throw "Could not find beszel-agent executable. Make sure it was properly installed."
|
||||||
}
|
}
|
||||||
@@ -127,8 +126,9 @@ try {
|
|||||||
if (-not (Test-Path $logDir)) {
|
if (-not (Test-Path $logDir)) {
|
||||||
New-Item -ItemType Directory -Path $logDir -Force | Out-Null
|
New-Item -ItemType Directory -Path $logDir -Force | Out-Null
|
||||||
}
|
}
|
||||||
nssm set beszel-agent AppStdout "$logDir\stdout.log"
|
$logFile = "$logDir\beszel-agent.log"
|
||||||
nssm set beszel-agent AppStderr "$logDir\stderr.log"
|
nssm set beszel-agent AppStdout $logFile
|
||||||
|
nssm set beszel-agent AppStderr $logFile
|
||||||
|
|
||||||
# Create a firewall rule if it doesn't exist
|
# Create a firewall rule if it doesn't exist
|
||||||
$ruleName = "Allow beszel-agent"
|
$ruleName = "Allow beszel-agent"
|
||||||
@@ -162,6 +162,7 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "Checking beszel-agent service status..."
|
Write-Host "Checking beszel-agent service status..."
|
||||||
|
Start-Sleep -Seconds 5 # Allow time to start before checking status
|
||||||
$serviceStatus = nssm status beszel-agent
|
$serviceStatus = nssm status beszel-agent
|
||||||
|
|
||||||
if ($serviceStatus -eq "SERVICE_RUNNING") {
|
if ($serviceStatus -eq "SERVICE_RUNNING") {
|
||||||
@@ -180,4 +181,4 @@ catch {
|
|||||||
if ($Elevated) {
|
if ($Elevated) {
|
||||||
Write-Host "Press any key to exit..." -ForegroundColor Cyan
|
Write-Host "Press any key to exit..." -ForegroundColor Cyan
|
||||||
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user