Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
01384741c2 | ||
|
|
54964e71c2 | ||
|
|
5f438bfb03 | ||
|
|
bd14f39105 | ||
|
|
1fa3e07920 |
7
.gitignore
vendored
7
.gitignore
vendored
@@ -1,6 +1,13 @@
|
|||||||
# Service builder executable outputs
|
# Service builder executable outputs
|
||||||
service/*.exe
|
service/*.exe
|
||||||
|
|
||||||
|
# Signed code
|
||||||
|
engine/*.*
|
||||||
|
|
||||||
|
|
||||||
# Installer outputs
|
# Installer outputs
|
||||||
builder/*.msi
|
builder/*.msi
|
||||||
builder/*.wixpdb
|
builder/*.wixpdb
|
||||||
|
|
||||||
|
# MSI Release
|
||||||
|
release/*.msi
|
||||||
|
|||||||
39
CHANGELOG.md
39
CHANGELOG.md
@@ -2,6 +2,45 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## Release 1.1.3 (2025-01-07)
|
||||||
|
|
||||||
|
[Full Changelog](https://github.com/webalexeu/winbgp/compare/v1.1.2...v1.1.3)
|
||||||
|
|
||||||
|
**Features**
|
||||||
|
|
||||||
|
- Add service start if feature is installed and routing enabled
|
||||||
|
|
||||||
|
**Bugfixes**
|
||||||
|
|
||||||
|
- [API restart cause failure of the engine](https://github.com/webalexeu/winbgp/issues/1)
|
||||||
|
|
||||||
|
## Release 1.1.2 (2025-01-06)
|
||||||
|
|
||||||
|
[Full Changelog](https://github.com/webalexeu/winbgp/compare/v1.1.1...v1.1.2)
|
||||||
|
|
||||||
|
**Features**
|
||||||
|
|
||||||
|
- Sign API/Engine/HealthCheck/CLI binaries
|
||||||
|
- Force process to exit when a failure occurs
|
||||||
|
|
||||||
|
**Bugfixes**
|
||||||
|
|
||||||
|
**Known Issues**
|
||||||
|
|
||||||
|
- API restart cause failure of the engine
|
||||||
|
|
||||||
|
## Release 1.1.1 (2024-12-30)
|
||||||
|
|
||||||
|
[Full Changelog](https://github.com/webalexeu/winbgp/compare/v1.1.0...v1.1.1)
|
||||||
|
|
||||||
|
**Features**
|
||||||
|
|
||||||
|
- Sign MSI installer
|
||||||
|
|
||||||
|
**Bugfixes**
|
||||||
|
|
||||||
|
**Known Issues**
|
||||||
|
|
||||||
## Release 1.1.0 (2024-12-20)
|
## Release 1.1.0 (2024-12-20)
|
||||||
|
|
||||||
**Features**
|
**Features**
|
||||||
|
|||||||
@@ -4,7 +4,11 @@ Param (
|
|||||||
[String] $Version,
|
[String] $Version,
|
||||||
[Parameter(Mandatory = $false)]
|
[Parameter(Mandatory = $false)]
|
||||||
[ValidateSet("amd64", "arm64")]
|
[ValidateSet("amd64", "arm64")]
|
||||||
[String] $Arch = "amd64"
|
[String] $Arch = "amd64",
|
||||||
|
[Parameter(ParameterSetName='Signing', Mandatory = $false)]
|
||||||
|
[Switch] $Sign = $false,
|
||||||
|
[Parameter(ParameterSetName='Signing', Mandatory = $false)]
|
||||||
|
[String] $CertificateThumbprint
|
||||||
)
|
)
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
@@ -18,6 +22,13 @@ Trap {
|
|||||||
Pop-Location
|
Pop-Location
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$cert=Get-ChildItem Cert:\CurrentUser\My -CodeSigningCert | Where-Object { $_.Thumbprint -eq $CertificateThumbprint }
|
||||||
|
Get-ChildItem -Path '..\src' | Where-Object {$_.Extension -eq '.ps1'} | ForEach-Object {
|
||||||
|
Copy-Item -Path $_.FullName -Destination "..\engine" -Force
|
||||||
|
if ($Sign) {
|
||||||
|
Set-AuthenticodeSignature -FilePath "..\engine\$($_.Name)" -TimestampServer 'http://time.certum.pl' -Certificate $cert
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Write-Verbose "Creating winbgp-${Version}-${Arch}.msi"
|
Write-Verbose "Creating winbgp-${Version}-${Arch}.msi"
|
||||||
$wixArch = @{"amd64" = "x64"; "arm64" = "arm64"}[$Arch]
|
$wixArch = @{"amd64" = "x64"; "arm64" = "arm64"}[$Arch]
|
||||||
@@ -26,3 +37,12 @@ Invoke-Expression "wix build -arch $wixArch -o .\WinBGP-$($Version)-$($Arch).msi
|
|||||||
|
|
||||||
Write-Verbose "Done!"
|
Write-Verbose "Done!"
|
||||||
Pop-Location
|
Pop-Location
|
||||||
|
|
||||||
|
# Clean temporary build folder
|
||||||
|
Remove-Item -Path "..\engine\*"
|
||||||
|
|
||||||
|
Copy-Item -Path "WinBGP-$($Version)-$($Arch).msi" -Destination "..\release" -Force
|
||||||
|
if ($Sign) {
|
||||||
|
& "C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x64\signtool.exe" sign /sha1 $CertificateThumbprint /tr http://time.certum.pl/ /td sha256 /fd sha256 /v "..\release\WinBGP-$($Version)-$($Arch).msi"
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
<Component Transitive="yes">
|
<Component Transitive="yes">
|
||||||
<File Id="winbgp_service" Source="..\service\WinBGP-Service.exe" KeyPath="yes" Vital="yes" Checksum="yes" />
|
<File Id="winbgp_service" Source="..\service\WinBGP-Service.exe" KeyPath="yes" Vital="yes" Checksum="yes" />
|
||||||
<ServiceInstall
|
<ServiceInstall
|
||||||
Id="InstallExporterService"
|
Id="InstallWinBGPService"
|
||||||
Name="WinBGP"
|
Name="WinBGP"
|
||||||
DisplayName="WinBGP Engine"
|
DisplayName="WinBGP Engine"
|
||||||
Description="The BGP swiss army knife of networking on Windows"
|
Description="The BGP swiss army knife of networking on Windows"
|
||||||
@@ -39,10 +39,10 @@
|
|||||||
<ServiceDependency Id="RemoteAccess" />
|
<ServiceDependency Id="RemoteAccess" />
|
||||||
</ServiceInstall>
|
</ServiceInstall>
|
||||||
<ServiceControl
|
<ServiceControl
|
||||||
Id="MyServiceControl"
|
Id="WinBGPServiceControl"
|
||||||
Name="WinBGP"
|
Name="WinBGP"
|
||||||
|
Stop="both"
|
||||||
Remove="both"
|
Remove="both"
|
||||||
Stop="both"
|
|
||||||
Wait="yes" />
|
Wait="yes" />
|
||||||
</Component>
|
</Component>
|
||||||
</DirectoryRef>
|
</DirectoryRef>
|
||||||
|
|||||||
@@ -74,6 +74,14 @@
|
|||||||
ExeCommand="powershell.exe -ExecutionPolicy Bypass -Command "if ((Get-RemoteAccess).RoutingStatus -ne 'Installed') { Write-Host 'Enabling routing (WinBGP prerequisite)'; Install-RemoteAccess -VpnType RoutingOnly }""
|
ExeCommand="powershell.exe -ExecutionPolicy Bypass -Command "if ((Get-RemoteAccess).RoutingStatus -ne 'Installed') { Write-Host 'Enabling routing (WinBGP prerequisite)'; Install-RemoteAccess -VpnType RoutingOnly }""
|
||||||
Return="check"
|
Return="check"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<CustomAction Id="ServiceStart"
|
||||||
|
Execute="immediate"
|
||||||
|
Impersonate="no"
|
||||||
|
Directory="TARGETDIR"
|
||||||
|
ExeCommand="powershell.exe -ExecutionPolicy Bypass -Command "if ((Get-RemoteAccess).RoutingStatus -eq 'Installed') { Write-Host 'Starting WinBGP service'; Start-Service -Name WinBGP -ErrorAction SilentlyContinue }""
|
||||||
|
Return="ignore"
|
||||||
|
/>
|
||||||
|
|
||||||
<CustomAction Id="RemoveConfig"
|
<CustomAction Id="RemoveConfig"
|
||||||
Execute="deferred"
|
Execute="deferred"
|
||||||
@@ -90,8 +98,9 @@
|
|||||||
<Custom Action="GenerateConfig" After="InstallFiles" Condition="NOT Installed AND NOT WIX_UPGRADE_DETECTED AND NOT WIX_DOWNGRADE_DETECTED" />
|
<Custom Action="GenerateConfig" After="InstallFiles" Condition="NOT Installed AND NOT WIX_UPGRADE_DETECTED AND NOT WIX_DOWNGRADE_DETECTED" />
|
||||||
<Custom Action="EnableWindowsFeature" After="InstallFiles" Condition="&Features=3 AND NOT Installed AND (MsiNTProductType=2 OR MsiNTProductType=3)" />
|
<Custom Action="EnableWindowsFeature" After="InstallFiles" Condition="&Features=3 AND NOT Installed AND (MsiNTProductType=2 OR MsiNTProductType=3)" />
|
||||||
<Custom Action="EnableWindowsFeatureRSAT" After="EnableWindowsFeature" Condition="&Features=3 AND NOT Installed AND (MsiNTProductType=2 OR MsiNTProductType=3)" />
|
<Custom Action="EnableWindowsFeatureRSAT" After="EnableWindowsFeature" Condition="&Features=3 AND NOT Installed AND (MsiNTProductType=2 OR MsiNTProductType=3)" />
|
||||||
<Custom Action="EnableRouting" After="EnableWindowsFeatureRSAT" Condition="&Features=3 AND NOT Installed AND (MsiNTProductType=2 OR MsiNTProductType=3)" /> <!-- TO CHECK to use Condition="MAINTENANCE" for upgrade -->
|
<Custom Action="EnableRouting" After="EnableWindowsFeatureRSAT" Condition="&Features=3 AND NOT Installed AND (MsiNTProductType=2 OR MsiNTProductType=3)" />
|
||||||
<ScheduleReboot After="InstallFinalize" Condition="&Features=3 AND NOT Installed AND (MsiNTProductType=2 OR MsiNTProductType=3)" /> <!-- TO CHECK <Condition>REBOOT_REQUIRED</Condition> -->
|
<Custom Action="ServiceStart" After="InstallFinalize" Condition='NOT REMOVE="ALL" AND (MsiNTProductType=2 OR MsiNTProductType=3)' />
|
||||||
|
<ScheduleReboot After="InstallFinalize" Condition="&Features=3 AND NOT Installed AND NOT (WIX_UPGRADE_DETECTED OR UPGRADINGPRODUCTCODE) AND (MsiNTProductType=2 OR MsiNTProductType=3)" /> <!-- TO CHECK <Condition>REBOOT_REQUIRED</Condition> -->
|
||||||
<Custom Action='RemoveConfig' Before='RemoveFiles' Condition='Installed AND (REMOVE="ALL") AND NOT (WIX_UPGRADE_DETECTED OR UPGRADINGPRODUCTCODE)' />
|
<Custom Action='RemoveConfig' Before='RemoveFiles' Condition='Installed AND (REMOVE="ALL") AND NOT (WIX_UPGRADE_DETECTED OR UPGRADINGPRODUCTCODE)' />
|
||||||
</InstallExecuteSequence>
|
</InstallExecuteSequence>
|
||||||
|
|
||||||
@@ -167,13 +176,13 @@
|
|||||||
<StandardDirectory Id="ProgramFiles64Folder">
|
<StandardDirectory Id="ProgramFiles64Folder">
|
||||||
<Directory Id="APPLICATIONFOLDER" Name="WinBGP">
|
<Directory Id="APPLICATIONFOLDER" Name="WinBGP">
|
||||||
<Component Id="winbgp_engine" Guid="a7b5748a-16c9-4594-85ad-de032fb3f39c">
|
<Component Id="winbgp_engine" Guid="a7b5748a-16c9-4594-85ad-de032fb3f39c">
|
||||||
<File Id="winbgp_engine" Source="..\src\WinBGP-Engine.ps1" KeyPath="yes" Vital="yes" Checksum="yes" />
|
<File Id="winbgp_engine" Source="..\engine\WinBGP-Engine.ps1" KeyPath="yes" Vital="yes" Checksum="yes" />
|
||||||
</Component>
|
</Component>
|
||||||
<Component Id="winbgp_healthcheck" Guid="8a356315-8307-4508-b19d-00eb05e59428">
|
<Component Id="winbgp_healthcheck" Guid="8a356315-8307-4508-b19d-00eb05e59428">
|
||||||
<File Id="winbgp_healthcheck" Source="..\src\WinBGP-HealthCheck.ps1" KeyPath="yes" Vital="yes" Checksum="yes" />
|
<File Id="winbgp_healthcheck" Source="..\engine\WinBGP-HealthCheck.ps1" KeyPath="yes" Vital="yes" Checksum="yes" />
|
||||||
</Component>
|
</Component>
|
||||||
<Component Id="winbgp_api" Guid="77de0ab1-0e53-4967-9469-142f49b397a4">
|
<Component Id="winbgp_api" Guid="77de0ab1-0e53-4967-9469-142f49b397a4">
|
||||||
<File Id="winbgp_api" Source="..\src\WinBGP-API.ps1" KeyPath="yes" Vital="yes" Checksum="yes" />
|
<File Id="winbgp_api" Source="..\engine\WinBGP-API.ps1" KeyPath="yes" Vital="yes" Checksum="yes" />
|
||||||
</Component>
|
</Component>
|
||||||
<Component Id="winbgp_config" Guid="03063c39-1063-4126-b974-5cad888d5804" NeverOverwrite="yes" Permanent="yes" >
|
<Component Id="winbgp_config" Guid="03063c39-1063-4126-b974-5cad888d5804" NeverOverwrite="yes" Permanent="yes" >
|
||||||
<File Id="winbgp_config" Name="winbgp.json" Source="..\src\winbgp.json.example" KeyPath="yes" Checksum="yes" />
|
<File Id="winbgp_config" Name="winbgp.json" Source="..\src\winbgp.json.example" KeyPath="yes" Checksum="yes" />
|
||||||
@@ -182,7 +191,7 @@
|
|||||||
<File Id="winbgp_config_example" Source="..\src\winbgp.json.example" KeyPath="yes" Checksum="yes" />
|
<File Id="winbgp_config_example" Source="..\src\winbgp.json.example" KeyPath="yes" Checksum="yes" />
|
||||||
</Component>
|
</Component>
|
||||||
<Component Id="winbgp_cli" Guid="b74d4be4-3de4-4006-a271-b56d078d2bcc">
|
<Component Id="winbgp_cli" Guid="b74d4be4-3de4-4006-a271-b56d078d2bcc">
|
||||||
<File Id="winbgp_cli" Source="..\src\WinBGP.ps1" KeyPath="yes" Vital="yes" Checksum="yes" />
|
<File Id="winbgp_cli" Source="..\engine\WinBGP.ps1" KeyPath="yes" Vital="yes" Checksum="yes" />
|
||||||
</Component>
|
</Component>
|
||||||
</Directory>
|
</Directory>
|
||||||
</StandardDirectory>
|
</StandardDirectory>
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ Param(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Don't forget to increment version when updating engine
|
# Don't forget to increment version when updating engine
|
||||||
$scriptVersion = '1.1.0'
|
$scriptVersion = '1.1.1'
|
||||||
|
|
||||||
|
|
||||||
# This script name, with various levels of details
|
# This script name, with various levels of details
|
||||||
@@ -66,6 +66,9 @@ $scriptFullName = $argv0.fullname # Ex: C:\Temp\PSService.ps1
|
|||||||
# Global settings
|
# Global settings
|
||||||
$serviceName = "WinBGP" # A one-word name used for net start commands
|
$serviceName = "WinBGP" # A one-word name used for net start commands
|
||||||
$serviceDisplayName = "WinBGP"
|
$serviceDisplayName = "WinBGP"
|
||||||
|
# To improve (Service name should be rationalized)
|
||||||
|
$serviceInternalName = "$($serviceName)-Service"
|
||||||
|
$engineName = "$($serviceName)-Engine"
|
||||||
$ServiceDescription = "The BGP swiss army knife of networking on Windows"
|
$ServiceDescription = "The BGP swiss army knife of networking on Windows"
|
||||||
$pipeName = "Service_$serviceName" # Named pipe name. Used for sending messages to the service task
|
$pipeName = "Service_$serviceName" # Named pipe name. Used for sending messages to the service task
|
||||||
$installDir = "${ENV:ProgramW6432}\$serviceDisplayName" # Where to install the service files
|
$installDir = "${ENV:ProgramW6432}\$serviceDisplayName" # Where to install the service files
|
||||||
@@ -984,12 +987,14 @@ function Stop-API() {
|
|||||||
$ProcessID=$null
|
$ProcessID=$null
|
||||||
$ApiPID=$null
|
$ApiPID=$null
|
||||||
# Get service PID
|
# Get service PID
|
||||||
$ProcessID=(Get-CimInstance Win32_Process -Filter "name = 'powershell.exe'" -OperationTimeoutSec 1 | Where-Object {$_.CommandLine -like "*'$installDir\$serviceDisplayName.ps1' -Service*"}).ProcessId
|
$ProcessID=(Get-CimInstance Win32_Process -Filter "name = 'powershell.exe'" -OperationTimeoutSec 1 | Where-Object {$_.CommandLine -like "*'$installDir\$engineName.ps1' -Service*"}).ProcessId
|
||||||
if ($ProcessID) {
|
if ($ProcessID) {
|
||||||
# Get API PID
|
# Get API PID
|
||||||
$ApiPID=(Get-WmiObject win32_process -filter "Name='powershell.exe' AND ParentProcessId=$ProcessID").ProcessId
|
$ApiPID=(Get-WmiObject win32_process -filter "Name='powershell.exe' AND ParentProcessId=$ProcessID").ProcessId
|
||||||
|
if ($ApiPID) {
|
||||||
|
Stop-Process -Id $ApiPID -Force -ErrorAction SilentlyContinue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Stop-Process -Id $ApiPID -Force -ErrorAction SilentlyContinue
|
|
||||||
Stop-Job -Name 'API' -ErrorAction SilentlyContinue
|
Stop-Job -Name 'API' -ErrorAction SilentlyContinue
|
||||||
Remove-Job -Name 'API' -Force -ErrorAction SilentlyContinue
|
Remove-Job -Name 'API' -Force -ErrorAction SilentlyContinue
|
||||||
}
|
}
|
||||||
@@ -1115,9 +1120,10 @@ if ($Service) { # Run the service
|
|||||||
$configuration = Get-Content -Path $configdir | ConvertFrom-Json
|
$configuration = Get-Content -Path $configdir | ConvertFrom-Json
|
||||||
Write-Log "Loading configuration file '$($configdir)'"
|
Write-Log "Loading configuration file '$($configdir)'"
|
||||||
} else {
|
} else {
|
||||||
Write-Log "Configuration file '$($configdir)' is not valid - Stopping $($serviceDisplayName) process" -Level Error
|
Write-Log "Configuration file '$($configdir)' is not valid" -Level Warning
|
||||||
|
Write-Log "Stopping $($serviceInternalName) process" -Level Error
|
||||||
# Forcing stop process so service will know that process is not running
|
# Forcing stop process so service will know that process is not running
|
||||||
Stop-Process -Name $serviceDisplayName -Force
|
Stop-Process -Name $serviceInternalName -Force
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1533,7 +1539,7 @@ if ($Service) { # Run the service
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Write-Log "Reload aborted - Configuration file '$($configdir)' is not a valid JSON file" -Level Error
|
Write-Log "Reload aborted - Configuration file '$($configdir)' is not a valid JSON file" -Level Warning
|
||||||
}
|
}
|
||||||
$pipeThread = Start-PipeHandlerThread $pipeName -Event "ControlMessage"
|
$pipeThread = Start-PipeHandlerThread $pipeName -Event "ControlMessage"
|
||||||
}
|
}
|
||||||
@@ -1728,6 +1734,9 @@ if ($Service) { # Run the service
|
|||||||
$msg = $_.Exception.Message
|
$msg = $_.Exception.Message
|
||||||
$line = $_.InvocationInfo.ScriptLineNumber
|
$line = $_.InvocationInfo.ScriptLineNumber
|
||||||
Write-Log -Message "Error at line ${line}: $msg" -Level Error
|
Write-Log -Message "Error at line ${line}: $msg" -Level Error
|
||||||
|
Write-Log "Stopping $($serviceInternalName) process" -Level Error
|
||||||
|
# Forcing stop process so service will know that process is not running (to avoid having service running without process)
|
||||||
|
Stop-Process -Name $serviceInternalName -Force
|
||||||
} finally { # Invoked in all cases: Exception or normally by -Stop
|
} finally { # Invoked in all cases: Exception or normally by -Stop
|
||||||
# Cleanup the periodic timer used in the above example
|
# Cleanup the periodic timer used in the above example
|
||||||
Unregister-Event -SourceIdentifier $timerName
|
Unregister-Event -SourceIdentifier $timerName
|
||||||
|
|||||||
Reference in New Issue
Block a user