mirror of
https://github.com/okieselbach/AutopilotMonitor.git
synced 2026-10-25 05:00:07 +00:00
6ebdfa41af
The agent log directory mixed three conventions (agent_20260817.log, bootstrap_agent.log, msi-bootstrap.log) while everything else in the diagnostics ZIP is already kebab-case. All log files now follow <component>-<content>.log: agent.log (was agent_YYYYMMDD.log; segments agent-NNN.log) bootstrap-script.log (was bootstrap_agent.log; script v2.4) bootstrap-msi.log (was msi-bootstrap.log) crash-<utc>.log (was crash_<utc>.log) gather-rules-debug.log (was gather_rules_debug.log) ime-pattern-matches.log (was ime_pattern_matches.log) The date is dropped from the main log: the agent only lives for one enrollment, and date rotation split the chronology at local midnight - which can fall mid-enrollment while the clock is still on the OOBE default timezone. The existing 50MB size rotation stays as the growth bound. Legacy dated files are ignored by the rotation probe; crash detection still picks up legacy crash_*.log once so an in-place self-update cannot lose a pending crash classification. Diag collectors glob *.log and need no change. MCP zip-map and docs note the legacy names for archives from pre-rename agents. Settings UI hint paths updated. MSI rebuild + bootstrap script publish (v2.4) + MCP redeploy required to ship. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
56 lines
2.3 KiB
PowerShell
56 lines
2.3 KiB
PowerShell
# Invoke-BootstrapDownload.ps1 - thin runner embedded in the Bootstrap MSI.
|
|
#
|
|
# The MSI is only a delivery vehicle (MDM LOB channel installs earlier than the IME
|
|
# script/app batches during Autopilot Device Preparation). This runner downloads the
|
|
# CURRENT Install-AutopilotMonitor.ps1 from the download endpoint and executes it, so
|
|
# every piece of real bootstrap logic (guards, relax rules, agent download) stays
|
|
# server-updatable without re-shipping the MSI.
|
|
#
|
|
# Fail-soft by design: the runner always exits 0 so a transient network failure never
|
|
# marks the LOB install as failed; diagnostics go to bootstrap-msi.log.
|
|
# ASCII only - no special characters in this file.
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
$baseDir = Join-Path $env:ProgramData 'AutopilotMonitor'
|
|
$logDir = Join-Path $baseDir 'Logs'
|
|
New-Item -ItemType Directory -Force -Path $logDir | Out-Null
|
|
$log = Join-Path $logDir 'bootstrap-msi.log'
|
|
|
|
function Write-Log([string]$message) {
|
|
Add-Content -Path $log -Value ("[{0}] {1}" -f (Get-Date -Format 'yyyy-MM-dd HH:mm:ss'), $message)
|
|
}
|
|
|
|
try {
|
|
Write-Log "MSI bootstrap runner started (user=$env:USERNAME, pid=$PID)."
|
|
|
|
if (Test-Path 'HKLM:\SOFTWARE\AutopilotMonitor\Deployed') {
|
|
Write-Log 'Deployed marker present - skipping, another channel already installed the agent.'
|
|
exit 0
|
|
}
|
|
|
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
|
$url = 'https://download.autopilotmonitor.com/agent/Install-AutopilotMonitor.ps1'
|
|
$dest = Join-Path $baseDir 'Install-AutopilotMonitor.ps1'
|
|
|
|
for ($attempt = 1; $attempt -le 3; $attempt++) {
|
|
try {
|
|
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $dest
|
|
break
|
|
} catch {
|
|
Write-Log "Download attempt $attempt failed: $_"
|
|
if ($attempt -eq 3) { throw }
|
|
Start-Sleep -Seconds 10
|
|
}
|
|
}
|
|
|
|
Write-Log "Bootstrap script downloaded to $dest - executing."
|
|
# PS 5.1 file redirection (*>>) writes UTF-16LE, which garbles a log otherwise
|
|
# written via Add-Content (ANSI). Route through Add-Content for one encoding.
|
|
& $dest *>&1 | ForEach-Object { $_.ToString() } | Add-Content -Path $log
|
|
Write-Log "Bootstrap script finished (exit code $LASTEXITCODE)."
|
|
exit 0
|
|
} catch {
|
|
Write-Log ("MSI bootstrap runner failed: " + ($_ | Out-String))
|
|
exit 0
|
|
}
|