- Fix Windows $AgentBinary undefined (F-1) - Add Windows admin/UAC check (F-2) - Fix dashboard saves .ps1 not .bat (F-5) - Fix Windows config path inconsistency (F-6) - Fix Linux duplicate variable declarations (F-9) - Fix Linux duplicate step numbering (F-10) - Document emoji exemption for installer UX output 163 tests pass. No regressions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5.4 KiB
Installer Fix1 Implementation
Date: 2026-03-29 Branch: culurien
Summary
Fixed 6 bugs and performed ETHOS cleanup on the existing installer templates and dashboard code. No new features.
Files Changed
1. aggregator-server/internal/services/templates/install/scripts/windows.ps1.tmpl
F-1 (HIGH): $AgentBinary undefined
- Line 204 referenced
$AgentPathand$AgentDirwhich were never defined - Added
$AgentBinary = Join-Path $InstallDir "redflag-agent.exe"before the registration block $InstallDiris defined at line 15 asC:\Program Files\RedFlag- Registration now correctly resolves to
C:\Program Files\RedFlag\redflag-agent.exe
F-2 (HIGH): No admin/UAC check
- Added
#Requires -RunAsAdministratordirective at top of script - Added runtime
IsInRolecheck with clear error messages (no emoji) - Script now fails immediately with actionable instructions if not elevated
2. aggregator-web/src/pages/settings/AgentManagement.tsx
F-5 (MEDIUM): Dashboard saves .bat instead of .ps1
- Changed
-OutFile install.bat; .\install.batto-OutFile install.ps1; powershell -ExecutionPolicy Bypass -File install.ps1 - Added
-UseBasicParsingflag toiwr(required on older Windows) - The install script is PowerShell, not batch — the old
.batextension caused Windows to try running it as CMD
3. aggregator-agent/internal/service/windows.go
F-6 (MEDIUM): Windows config path inconsistency
getConfigPath()hardcodedC:\ProgramData\RedFlag\config.json(noagentsubdir)constants.GetAgentConfigPath()returnsC:\ProgramData\RedFlag\agent\config.json- The agent's
main.gousesconstants.GetAgentConfigPath()for registration, loading, and saving - Canonical path:
C:\ProgramData\RedFlag\agent\config.json(withagentsubdir) - Fix: Changed
getConfigPath()to callconstants.GetAgentConfigPath() - The
constantspackage was already imported inwindows.go
Decision rationale: The main.go registration flow (lines 219, 265, 468) consistently uses constants.GetAgentConfigPath(). The installer template creates config at C:\ProgramData\RedFlag\config.json — this means fresh Windows installs via the installer template would create config in one location while the Windows service reads from another. By making the service use constants.GetAgentConfigPath(), both paths converge. The installer template's config path ($ConfigDir\config.json where $ConfigDir = C:\ProgramData\RedFlag) will need a separate fix to include the agent subdirectory — flagged as future work.
4. aggregator-server/internal/services/templates/install/scripts/linux.sh.tmpl
F-9 (LOW): Duplicate variable declarations
- Lines 16-22 and 41-53 both declared
CONFIG_DIR,LOG_DIR,AGENT_USER,SUDOERS_FILE - Merged into a single variables block (lines 16-31) containing all static and template variables
- No values changed — all duplicates had identical values
F-10 (LOW): Duplicate step numbering
- Two "Step 4" and two "Step 5" existed
- Renumbered sequentially: Steps 1-11 (was 1-5, 4-9)
- No content changed — only the comment labels
5. Emoji Decision (F-7, F-8)
Decision: KEPT. Not an ETHOS violation.
All emoji in both templates (linux.sh.tmpl, windows.ps1.tmpl) are in user-facing terminal output (echo, Write-Host). Examples:
echo "... Existing installation detected..."(checkmark for user feedback)Write-Host "... Installation complete!" -ForegroundColor Green
ETHOS #1 applies to server log statements (log.Printf, structured logging). Installer scripts are user-facing CLI tools — their terminal output is equivalent to the setup wizard and terminal display, which have an existing exemption. No emoji appear in log file output or structured logging.
Manual Test Plan
Linux
- Run install script on Ubuntu 22.04 (fresh VM or container)
- Confirm service starts:
systemctl status redflag-agent - Run script again (idempotency test)
- Confirm backup created for existing install
- Verify step numbers display sequentially in output
Windows
- Run script in PowerShell as Administrator
- Confirm admin check blocks non-elevated execution
- Confirm
$AgentBinaryresolves toC:\Program Files\RedFlag\redflag-agent.exe - Confirm service created:
Get-Service RedFlagAgent - Run script again (idempotency test)
Dashboard
- Generate Linux one-liner from AgentManagement page
- Generate Windows one-liner — confirm filename is
.ps1not.bat - Confirm Windows command includes
-ExecutionPolicy Bypass
Note: Template changes cannot be automatically tested via Go tests (they are rendered shell/PowerShell scripts). Manual verification on target platforms is required.
Go Test Results
Server: 7 packages passed, 0 failures (103 tests)
Agent: 10 packages passed, 0 failures (60 tests)
Total: 163 tests, 0 failures
TypeScript: 0 errors
ETHOS Pre-Integration Checklist
$AgentBinaryundefined bug fixed (Windows)- Admin check added (Windows)
- Dashboard outputs
.ps1not.bat - Config path consistent across Windows code
- Duplicate variables removed (Linux)
- Duplicate step numbers fixed (Linux)
- Emoji decision documented (keep UX, exempt from ETHOS #1)
- All Go tests pass
- No banned words in new template text
- No new
fmt.Printfin server Go code