Bug fixes

- Add `-UseBasicParsing` flag to release request
- Move logs directory creation to server service section
- Fix cleanup task only running when the file doesn't exist
This commit is contained in:
Corbin 2026-01-15 09:58:29 -05:00
parent 4a54e482cd
commit 4e18db759e

View File

@ -21,7 +21,7 @@ param (
#> #>
begin { begin {
$Releases = (Invoke-WebRequest 'https://api.github.com/repos/ar51an/iperf3-win-builds/releases').Content | ConvertFrom-Json | Where-Object { $_.prerelease -eq $false -and $_.draft -eq $false } $Releases = (Invoke-WebRequest 'https://api.github.com/repos/ar51an/iperf3-win-builds/releases' -UseBasicParsing).Content | ConvertFrom-Json | Where-Object { $_.prerelease -eq $false -and $_.draft -eq $false }
$ReleaseTag = ($Releases | Select-Object -First 1).tag_name $ReleaseTag = ($Releases | Select-Object -First 1).tag_name
$InstallerUrl = "https://github.com/ar51an/iperf3-win-builds/releases/download/$ReleaseTag/iperf-$ReleaseTag-win64.zip" $InstallerUrl = "https://github.com/ar51an/iperf3-win-builds/releases/download/$ReleaseTag/iperf-$ReleaseTag-win64.zip"
@ -55,11 +55,6 @@ begin {
process { process {
if (-not $iPerf3Installed) { if (-not $iPerf3Installed) {
Write-Host "Installing iPerf3..." Write-Host "Installing iPerf3..."
# Prep
# Create the logs directory if it doesn't already exist
if (-not (Test-Path -PathType Container (Join-Path -Path $DestinationPath -ChildPath 'logs'))) { New-Item -ItemType Directory -Path (Join-Path -Path $DestinationPath -ChildPath 'logs') | Out-Null }
# Download # Download
try { try {
@ -93,6 +88,13 @@ process {
try { try {
Write-Host "Installing server service..." Write-Host "Installing server service..."
$LogPath = Join-Path -Path $DestinationPath -ChildPath 'logs'
$LogName = 'service.log'
$LogFullName = Join-Path -Path $LogPath -ChildPath $LogName
# Create the logs directory if it doesn't already exist
if (-not (Test-Path -PathType Container $LogPath)) { New-Item -ItemType Directory -Path $LogPath | Out-Null }
# Install the iperf3server service # Install the iperf3server service
if ((Get-CimInstance Win32_OperatingSystem).OSArchitecture) { if ((Get-CimInstance Win32_OperatingSystem).OSArchitecture) {
$NssmExecutable = 'C:\Program Files\nssm\win64\nssm.exe' $NssmExecutable = 'C:\Program Files\nssm\win64\nssm.exe'
@ -102,8 +104,8 @@ process {
& "$NssmExecutable" install iperf3server "$ExecutablePath" "--server --port 5201 --format m --verbose" & "$NssmExecutable" install iperf3server "$ExecutablePath" "--server --port 5201 --format m --verbose"
& "$NssmExecutable" set iperf3server DisplayName "iPerf3 Server" | Out-Null & "$NssmExecutable" set iperf3server DisplayName "iPerf3 Server" | Out-Null
& "$NssmExecutable" set iperf3server Description "iPerf3 is a tool for active measurements of the maximum achievable bandwidth on IP networks." | Out-Null & "$NssmExecutable" set iperf3server Description "iPerf3 is a tool for active measurements of the maximum achievable bandwidth on IP networks." | Out-Null
& "$NssmExecutable" set iperf3server AppStdout "$(Join-Path -Path $DestinationPath -ChildPath 'logs\service.log')" | Out-Null & "$NssmExecutable" set iperf3server AppStdout "$LogFullName" | Out-Null
& "$NssmExecutable" set iperf3server AppStderr "$(Join-Path -Path $DestinationPath -ChildPath 'logs\service.log')" | Out-Null & "$NssmExecutable" set iperf3server AppStderr "$LogFullName" | Out-Null
Write-Host "Starting service..." Write-Host "Starting service..."
Start-Service -Name iperf3server Start-Service -Name iperf3server
@ -116,7 +118,7 @@ process {
end { end {
# Clean up # Clean up
if (-not (Test-Path -Path $ArchivePath)) { if (Test-Path -Path $ArchivePath) {
Write-Host "Removing iPerf package download from '$ArchivePath'" Write-Host "Removing iPerf package download from '$ArchivePath'"
Remove-Item -Path $ArchivePath -Force Remove-Item -Path $ArchivePath -Force
} }