Compare commits
2 Commits
9a6b91f3ed
...
0d4eb555bd
| Author | SHA1 | Date | |
|---|---|---|---|
| 0d4eb555bd | |||
| a93bf5d923 |
@ -42,8 +42,7 @@ begin {
|
|||||||
$ServerServiceInstalled = $true
|
$ServerServiceInstalled = $true
|
||||||
Write-Host 'Server service already installed.'
|
Write-Host 'Server service already installed.'
|
||||||
} else {
|
} else {
|
||||||
if (-not (Test-Path 'C:\Program Files\nssm') ) {
|
if (-not (Get-Command 'nssm.exe') ) {
|
||||||
# if ('nssm' -notin $env:PATH) {
|
|
||||||
throw 'NSSM is not installed. Please install NSSM before attempting to install the server service.'
|
throw 'NSSM is not installed. Please install NSSM before attempting to install the server service.'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,7 +74,7 @@ process {
|
|||||||
Expand-Archive -Path $ArchivePath -DestinationPath $DestinationPath -Force
|
Expand-Archive -Path $ArchivePath -DestinationPath $DestinationPath -Force
|
||||||
|
|
||||||
# Add the DestinationPath to Path system environment variable
|
# Add the DestinationPath to Path system environment variable
|
||||||
if ($DestinationPath -notin $env:PATH) { [Environment]::SetEnvironmentVariable("Path", $env:Path + ";$DestinationPath\", [System.EnvironmentVariableTarget]::Machine) }
|
if ($DestinationPath -notin $env:PATH) { $env:PATH = $env:PATH + ";$DestinationPath\"; [Environment]::SetEnvironmentVariable("Path", $env:PATH, [System.EnvironmentVariableTarget]::Machine) }
|
||||||
|
|
||||||
# Add firewall rule allowing application executable
|
# Add firewall rule allowing application executable
|
||||||
if ('Allow iPerf3' -notin (Get-NetFirewallRule).DisplayName) { New-NetFirewallRule -DisplayName 'Allow iPerf3' -Direction Inbound -Program $ExecutablePath -RemoteAddress Any -Profile Any -Action Allow }
|
if ('Allow iPerf3' -notin (Get-NetFirewallRule).DisplayName) { New-NetFirewallRule -DisplayName 'Allow iPerf3' -Direction Inbound -Program $ExecutablePath -RemoteAddress Any -Profile Any -Action Allow }
|
||||||
|
|||||||
51
windows/Install-WinAcme.Tests.ps1
Normal file
51
windows/Install-WinAcme.Tests.ps1
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
Describe 'Install-WinAcme' {
|
||||||
|
BeforeAll {
|
||||||
|
function Uninstall-WinAcme {
|
||||||
|
param (
|
||||||
|
[string]$DestinationPath
|
||||||
|
)
|
||||||
|
|
||||||
|
# Remove the installation directory
|
||||||
|
if (Test-Path -Path $DestinationPath) {
|
||||||
|
Remove-Item -Path $DestinationPath -Recurse -Force
|
||||||
|
}
|
||||||
|
|
||||||
|
# Remove from PATH
|
||||||
|
$env:PATH = $env:PATH -replace [regex]::Escape("$DestinationPath\"), ''
|
||||||
|
[Environment]::SetEnvironmentVariable("Path", $env:PATH, [System.EnvironmentVariableTarget]::Machine)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Clean up any existing win-acme installation
|
||||||
|
Uninstall-WinAcme -DestinationPath 'C:\Program Files\win-acme'
|
||||||
|
|
||||||
|
# Load the Install-WinAcme function
|
||||||
|
Set-Item function:Install-WinAcme ([ScriptBlock]::Create((Get-Content -Raw $PSCommandPath.Replace('.Tests.ps1', '.ps1'))))
|
||||||
|
}
|
||||||
|
|
||||||
|
It 'Has the correct parameters' {
|
||||||
|
$params = (Get-Command Install-WinAcme).Parameters
|
||||||
|
|
||||||
|
$params.ContainsKey('DestinationPath') | Should -Be $true
|
||||||
|
$params['DestinationPath'].ParameterType.Name | Should -Be 'String'
|
||||||
|
}
|
||||||
|
|
||||||
|
It 'Should download and install win-acme without errors' {
|
||||||
|
{ Install-WinAcme -DestinationPath 'C:\Program Files\win-acme' } | Should -Not -Throw
|
||||||
|
}
|
||||||
|
|
||||||
|
It 'Should add win-acme to the system PATH' {
|
||||||
|
$env:PATH | Should -Match 'C:\\Program Files\\win-acme\\'
|
||||||
|
}
|
||||||
|
|
||||||
|
It 'Should create the win-acme installation directory' {
|
||||||
|
Test-Path -Path 'C:\Program Files\win-acme' | Should -Be $true
|
||||||
|
}
|
||||||
|
|
||||||
|
It 'Should create the wacs executable in the installation directory' {
|
||||||
|
Test-Path -Path 'C:\Program Files\win-acme\wacs.exe' | Should -Be $true
|
||||||
|
}
|
||||||
|
|
||||||
|
AfterAll {
|
||||||
|
Uninstall-WinAcme -DestinationPath 'C:\Program Files\win-acme'
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -18,7 +18,7 @@ param (
|
|||||||
|
|
||||||
begin {
|
begin {
|
||||||
# Prep
|
# Prep
|
||||||
$Releases = (Invoke-WebRequest 'https://api.github.com/repos/win-acme/win-acme/releases').Content | ConvertFrom-Json | Where-Object { $_.prerelease -eq $false -and $_.draft -eq $false }
|
$Releases = (Invoke-WebRequest 'https://api.github.com/repos/win-acme/win-acme/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/win-acme/win-acme/releases/download/v2.2.9.1701/win-acme.v2.2.9.1701.x64.pluggable.zip'
|
# $InstallerUrl = 'https://github.com/win-acme/win-acme/releases/download/v2.2.9.1701/win-acme.v2.2.9.1701.x64.pluggable.zip'
|
||||||
@ -50,7 +50,7 @@ process {
|
|||||||
Expand-Archive -Path $ArchivePath -DestinationPath $DestinationPath -Force
|
Expand-Archive -Path $ArchivePath -DestinationPath $DestinationPath -Force
|
||||||
|
|
||||||
# Add the DestinationPath to Path system environment variable
|
# Add the DestinationPath to Path system environment variable
|
||||||
if ($DestinationPath -notin $env:PATH) { [Environment]::SetEnvironmentVariable("Path", $env:Path + ";$DestinationPath\", [System.EnvironmentVariableTarget]::Machine) }
|
if ($DestinationPath -notin $env:PATH) { $env:PATH = $env:PATH + ";$DestinationPath\"; [Environment]::SetEnvironmentVariable("Path", $env:PATH, [System.EnvironmentVariableTarget]::Machine) }
|
||||||
} catch {
|
} catch {
|
||||||
throw "Failed installing application. $_"
|
throw "Failed installing application. $_"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,36 @@
|
|||||||
Describe 'Install-IPerf3' {
|
Describe 'Install-IPerf3' {
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
Set-Item function:Install-IPerf3 ([ScriptBlock]::Create((Get-Content -Raw 'windows\Install-iPerf3.ps1')))
|
function Uninstall-IPerf3 {
|
||||||
|
param (
|
||||||
|
[string]$DestinationPath = 'C:\Program Files\iPerf3'
|
||||||
|
)
|
||||||
|
|
||||||
|
# Stop and remove the service if it exists
|
||||||
|
if (Get-Service -Name iperf3server -ErrorAction SilentlyContinue) {
|
||||||
|
Stop-Service -Name iperf3server -Force
|
||||||
|
Remove-Service -Name iperf3server
|
||||||
|
}
|
||||||
|
|
||||||
|
# Remove the installation directory
|
||||||
|
if (Test-Path -Path $DestinationPath) {
|
||||||
|
Remove-Item -Path $DestinationPath -Recurse -Force
|
||||||
|
}
|
||||||
|
|
||||||
|
# Remove firewall rule
|
||||||
|
if ('Allow iPerf3' -in (Get-NetFirewallRule).DisplayName) {
|
||||||
|
Remove-NetFirewallRule -DisplayName 'Allow iPerf3'
|
||||||
|
}
|
||||||
|
|
||||||
|
# Remove from PATH
|
||||||
|
$env:PATH = $env:PATH -replace [regex]::Escape("$DestinationPath\"), ''
|
||||||
|
[Environment]::SetEnvironmentVariable("Path", $env:PATH, [System.EnvironmentVariableTarget]::Machine)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Clean up any existing iPerf3 installation
|
||||||
|
Uninstall-IPerf3 -DestinationPath 'C:\Program Files\iPerf3'
|
||||||
|
|
||||||
|
# Load the Install-iPerf3 function
|
||||||
|
Set-Item function:Install-IPerf3 ([ScriptBlock]::Create((Get-Content -Raw $PSCommandPath.Replace('.Tests.ps1', '.ps1'))))
|
||||||
}
|
}
|
||||||
|
|
||||||
It 'Has the correct parameters' {
|
It 'Has the correct parameters' {
|
||||||
@ -34,16 +64,6 @@ Describe 'Install-IPerf3' {
|
|||||||
$firewallRule = Get-NetFirewallRule -DisplayName 'Allow iPerf3' -ErrorAction SilentlyContinue
|
$firewallRule = Get-NetFirewallRule -DisplayName 'Allow iPerf3' -ErrorAction SilentlyContinue
|
||||||
$firewallRule | Should -Not -Be $null
|
$firewallRule | Should -Not -Be $null
|
||||||
}
|
}
|
||||||
|
|
||||||
AfterAll {
|
|
||||||
# Clean up any existing iPerf3 installation
|
|
||||||
if (Get-Service -Name iperf3server -ErrorAction SilentlyContinue) {
|
|
||||||
Stop-Service -Name iperf3server -Force
|
|
||||||
Remove-Service -Name iperf3server
|
|
||||||
}
|
|
||||||
Remove-Item -Path 'C:\Program Files\iPerf3' -Recurse -Force -ErrorAction SilentlyContinue
|
|
||||||
Remove-NetFirewallRule -DisplayName 'Allow iPerf3' -ErrorAction SilentlyContinue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Context 'With ServerService parameter' {
|
Context 'With ServerService parameter' {
|
||||||
@ -53,15 +73,9 @@ Describe 'Install-IPerf3' {
|
|||||||
$service | Should -Not -Be $null
|
$service | Should -Not -Be $null
|
||||||
$service.Status | Should -Be 'Running'
|
$service.Status | Should -Be 'Running'
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
AfterAll {
|
AfterAll {
|
||||||
# Clean up any existing iPerf3 installation
|
Uninstall-IPerf3 -DestinationPath 'C:\Program Files\iPerf3'
|
||||||
if (Get-Service -Name iperf3server -ErrorAction SilentlyContinue) {
|
|
||||||
Stop-Service -Name iperf3server -Force
|
|
||||||
Remove-Service -Name iperf3server
|
|
||||||
}
|
|
||||||
Remove-Item -Path 'C:\Program Files\iPerf3' -Recurse -Force -ErrorAction SilentlyContinue
|
|
||||||
Remove-NetFirewallRule -DisplayName 'Allow iPerf3' -ErrorAction SilentlyContinue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user