mirror of
https://github.com/bunny-lab-io/Borealis.git
synced 2025-12-16 09:25:48 -07:00
Hid Debug Messages in Updater
This commit is contained in:
21
Update.ps1
21
Update.ps1
@@ -1,11 +1,14 @@
|
|||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param()
|
param(
|
||||||
|
[switch]$Trace
|
||||||
|
)
|
||||||
|
|
||||||
$scriptDir = Split-Path $MyInvocation.MyCommand.Path -Parent
|
$scriptDir = Split-Path $MyInvocation.MyCommand.Path -Parent
|
||||||
$script:BorealisTlsInitialized = $false
|
$script:BorealisTlsInitialized = $false
|
||||||
$script:BorealisTrustedThumbprints = @()
|
$script:BorealisTrustedThumbprints = @()
|
||||||
$script:BorealisCallbackApplied = $false
|
$script:BorealisCallbackApplied = $false
|
||||||
$script:AgentPythonHttpHelper = ''
|
$script:AgentPythonHttpHelper = ''
|
||||||
|
$script:UpdateDebugEnabled = $Trace.IsPresent
|
||||||
$symbols = @{
|
$symbols = @{
|
||||||
Success = [char]0x2705
|
Success = [char]0x2705
|
||||||
Running = [char]0x23F3
|
Running = [char]0x23F3
|
||||||
@@ -26,6 +29,10 @@ function Write-UpdateLog {
|
|||||||
$normalized = if ($Level) { $Level } else { 'INFO' }
|
$normalized = if ($Level) { $Level } else { 'INFO' }
|
||||||
$normalized = $normalized.ToUpperInvariant()
|
$normalized = $normalized.ToUpperInvariant()
|
||||||
|
|
||||||
|
if ($normalized -eq 'DEBUG' -and -not $script:UpdateDebugEnabled) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (-not $Color) {
|
if (-not $Color) {
|
||||||
switch ($normalized) {
|
switch ($normalized) {
|
||||||
'WARN' { $Color = 'Yellow' }
|
'WARN' { $Color = 'Yellow' }
|
||||||
@@ -362,7 +369,7 @@ function Save-ServerCertificateCache {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Set-Content -Path $targetPath -Value $CertificatePem -Encoding UTF8
|
Set-Content -Path $targetPath -Value $CertificatePem -Encoding UTF8
|
||||||
Write-UpdateLog ("Cached server certificate to {0}" -f $targetPath) 'INFO'
|
Write-UpdateLog ("Saved Borealis Engine certificate to {0}" -f $targetPath) 'INFO'
|
||||||
return $targetPath
|
return $targetPath
|
||||||
} catch {
|
} catch {
|
||||||
Write-UpdateLog ("Failed to cache server certificate: {0}" -f $_.Exception.Message) 'WARN'
|
Write-UpdateLog ("Failed to cache server certificate: {0}" -f $_.Exception.Message) 'WARN'
|
||||||
@@ -548,11 +555,11 @@ function Initialize-BorealisTlsContext {
|
|||||||
$trusted = @()
|
$trusted = @()
|
||||||
$cachedCertPath = Get-ExistingServerCertificatePath -AgentRoot $AgentRoot
|
$cachedCertPath = Get-ExistingServerCertificatePath -AgentRoot $AgentRoot
|
||||||
if ($cachedCertPath) {
|
if ($cachedCertPath) {
|
||||||
Write-UpdateLog ("Using cached TLS certificate: {0}" -f $cachedCertPath) 'INFO'
|
Write-UpdateLog ("Attempting Borealis Engine connection using cached certificate: {0}" -f $cachedCertPath) 'INFO'
|
||||||
try {
|
try {
|
||||||
$trusted += Get-CertificatesFromPem -Path $cachedCertPath
|
$trusted += Get-CertificatesFromPem -Path $cachedCertPath
|
||||||
} catch {
|
} catch {
|
||||||
Write-UpdateLog ("Failed to load cached TLS certificate: {0}" -f $_.Exception.Message) 'WARN'
|
Write-UpdateLog ("Unable to load cached certificate; continuing without it ({0})." -f $_.Exception.Message) 'WARN'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -563,7 +570,7 @@ function Initialize-BorealisTlsContext {
|
|||||||
} else {
|
} else {
|
||||||
$script:BorealisTrustedThumbprints = @()
|
$script:BorealisTrustedThumbprints = @()
|
||||||
Write-Verbose "No Borealis TLS certificates located; loopback hosts will be allowed without CA verification."
|
Write-Verbose "No Borealis TLS certificates located; loopback hosts will be allowed without CA verification."
|
||||||
Write-UpdateLog "No TLS certificates found; falling back to loopback-only allowance." 'WARN'
|
Write-UpdateLog "No cached Borealis Engine certificate available yet; limiting TLS checks to loopback hosts." 'WARN'
|
||||||
}
|
}
|
||||||
|
|
||||||
Ensure-BorealisCertificateValidator
|
Ensure-BorealisCertificateValidator
|
||||||
@@ -828,9 +835,9 @@ function Invoke-AgentHttpRequest {
|
|||||||
|
|
||||||
$cafile = Get-ExistingServerCertificatePath -AgentRoot $AgentRoot
|
$cafile = Get-ExistingServerCertificatePath -AgentRoot $AgentRoot
|
||||||
if ($cafile) {
|
if ($cafile) {
|
||||||
Write-UpdateLog ("Using cached TLS certificate for helper: {0}" -f $cafile) 'DEBUG'
|
Write-UpdateLog ("Attempting to contact Borealis Engine using cached certificate: {0}" -f $cafile) 'INFO'
|
||||||
} else {
|
} else {
|
||||||
Write-UpdateLog "No TLS bundle available; helper will skip certificate validation for this request." 'WARN'
|
Write-UpdateLog "No cached Borealis Engine certificate found; establishing connection without validation." 'WARN'
|
||||||
}
|
}
|
||||||
$payload = @{
|
$payload = @{
|
||||||
method = $Method
|
method = $Method
|
||||||
|
|||||||
Reference in New Issue
Block a user