Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Make agent machine onboarding seamless

rcourtmand5589cc8ca11
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 4aedda46cc..1c45c8025c 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -1058,9 +1058,16 @@ profile and assignment columns, but embedded table framing must route through
13. Keep API-backed platform onboarding explicit across
`frontend-modern/src/components/Settings/infrastructureOperationsModel.tsx`,
`frontend-modern/src/components/Settings/InfrastructureInstallerSection.tsx`,
+ `frontend-modern/src/utils/agentInstallCommand.ts`,
`frontend-modern/src/components/Settings/useInfrastructureInstallState.tsx`,
`frontend-modern/src/components/Settings/InfrastructureWorkspace.tsx`, and
`frontend-modern/src/components/SetupWizard/SetupCompletionPanel.tsx`.
+ Machines/host onboarding means a Pulse Agent install with full host
+ telemetry, while agentless machine reachability remains Availability-owned.
+ Unix-family copied installer commands must run the shared installer
+ preflight before privilege escalation, verify the exact agent binary
+ artifact, and pass token-bearing installs through ephemeral `--token-file`
+ transport instead of raw service arguments.
TrueNAS must be presented as an API-backed source flow through Add
infrastructure first, not as a dedicated Unified Agent install profile. The
agent install path may remain available for optional later agent
@@ -3064,6 +3071,14 @@ clipboard transport: the rendered Linux/macOS/BSD and Windows install snippets
must already include the active token choice, custom-CA trust, insecure/plain-
HTTP handling, install-profile flags, and command-execution mode instead of
displaying one command and mutating it only during copy.
+For Unix-family host installs, that same seamless installer contract requires
+the copied command to fetch the shared installer into an ephemeral directory,
+run `install.sh --preflight-only` before privilege escalation, and fail before
+`sudo` if the selected Pulse URL or exact `/download/pulse-agent?arch=...`
+artifact is unavailable or missing checksum metadata. Token-bearing copied
+commands must pass the credential to the installer through an ephemeral
+`--token-file` and clean it up with the downloaded installer script, so the
+installed service never receives a raw `--token` argument.
That same Windows install boundary must preserve the canonical server URL even
for the interactive PowerShell snippet: copied commands that still prompt for a
token must export `PULSE_URL` before invoking `install.ps1`, so the selected
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index fd47d3c3ba..59c125d6bb 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -280,6 +280,10 @@ platform page needs source-native backup columns.
payload phases; it does not create a second node setup API model or allow
page-local payload ownership.
32. `internal/api/agent_install_command_shared.go` shared with `agent-lifecycle`: agent install command assembly is both an agent lifecycle control surface and a canonical API payload contract boundary.
+ Frontend and backend Unix install command builders must stay on the same
+ token-file and preflight transport contract: tokens are passed to the
+ installer as ephemeral files, and host install snippets must verify the
+ target Pulse URL plus exact agent binary artifact before root escalation.
33. `internal/api/ai_handler.go` shared with `ai-runtime`: Pulse Assistant handlers are both an AI runtime control surface and a canonical API payload contract boundary.
Assistant session list payloads may expose only the safe
`handoff_summary` projection needed by the browser to mark and restore a
@@ -402,6 +406,10 @@ platform page needs source-native backup columns.
49. `internal/api/slo.go` shared with `performance-and-scalability`: the SLO endpoint is both an API contract surface and a protected performance hot-path boundary.
50. `internal/api/system_settings.go` shared with `security-privacy`: the system settings telemetry and auth controls are both a security/privacy control surface and a canonical API payload contract boundary.
51. `internal/api/unified_agent.go` shared with `agent-lifecycle`: unified agent download and installer handlers are both an agent lifecycle control surface and a canonical API payload contract boundary.
+ Development-mode missing-binary responses must report the build command
+ for the requested normalized OS/architecture, not a hard-coded Linux
+ target, so installer preflight failures point operators at the artifact
+ they actually need.
52. `internal/api/updates.go` shared with `deployment-installability`: update handlers are both a deployment-installability control surface and a canonical API payload contract boundary.
The platform-connections API contract also owns inactive monitored-system
candidate semantics end to end. `enabled=false` on TrueNAS or VMware preview,
@@ -3628,6 +3636,13 @@ parity: the rendered Linux/macOS/BSD and Windows install snippets in
transport, insecure/plain-HTTP behavior, install-profile env/flags, and
command-execution mode, rather than showing a stale base command that is only
rewritten at copy time.
+For Unix-family frontend-generated install snippets, that same contract also
+owns the preflight and credential transport shape: the rendered command must
+download the shared installer into an ephemeral directory, run
+`install.sh --preflight-only` before root/sudo escalation, verify that
+`/download/pulse-agent?arch=...` is reachable with checksum metadata, and
+pass selected tokens to the installer through an ephemeral `--token-file`
+instead of a raw `--token` service argument.
The loopback-originated install and setup payloads now also preserve the full
configured `PublicURL` when that URL is the canonical external route, instead
of rewriting only the host and inheriting an `http://` request-local scheme
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index f01d5a2d3f..438bf0631b 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -1445,6 +1445,14 @@ On token-optional Pulse instances, that same governed install surface must
support both valid paths: no-token transport after explicit confirmation, and
credentialed transport when the operator still generates a real token. Optional
auth may not silently downgrade the settings surface to tokenless-only mode.
+For Unix-family copied host installs, the deployment-owned shell installer must
+support preflight before privilege escalation: `--preflight-only` may run
+without root, must check both `/api/health` and the exact
+`/download/pulse-agent?arch=...` artifact for checksum metadata, and must fail
+before installation if the server cannot provide that binary. Token-bearing
+copy-paste commands must pass credentials through ephemeral `--token-file`
+transport and leave the installed service configured with the persistent
+runtime token file, never a raw `--token` process argument.
That Windows installer-owned state must also be cleared after successful
PowerShell uninstall, so a removed installation does not leave stale ProgramData
identity or transport continuity behind for later lifecycle commands.
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index ebee0b387e..eb88863e10 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -448,6 +448,12 @@ recovery scope, or a storage/recovery-owned secret source.
checksum or detached-signature vocabulary away from the canonical
`X-Checksum-Sha256`, `X-Signature-Ed25519`, and base64-encoded
`X-Signature-SSHSIG` contract.
+ When that adjacent unified-agent download path is missing a local dev
+ binary, its operator guidance must remain scoped to the requested
+ OS/architecture. Storage/recovery-adjacent support flows may observe that
+ error, but they must not hard-code a Linux-only rebuild command or infer
+ recovery ownership from a missing macOS, Windows, FreeBSD, or Linux agent
+ artifact.
That same adjacent API boundary also owns pre-auth local recovery
containment. Storage- and recovery-adjacent quick setup or break-glass
routes may exist before auth is configured, but they must stay
diff --git a/frontend-modern/src/components/Settings/InfrastructureInstallerSection.tsx b/frontend-modern/src/components/Settings/InfrastructureInstallerSection.tsx
index 21126aeba2..c13be840ca 100644
--- a/frontend-modern/src/components/Settings/InfrastructureInstallerSection.tsx
+++ b/frontend-modern/src/components/Settings/InfrastructureInstallerSection.tsx
@@ -54,7 +54,7 @@ const INSTALLER_FOCUS_PRESENTATION: Record<
'Start here to add the first system you want Pulse to monitor, then expand into Docker, Kubernetes, Proxmox, and related infrastructure.',
recommendationTitle: 'Recommended install model',
recommendationDetail:
- 'Pulse Agent is a low-overhead background service. Install it on each machine where you want full node-local telemetry such as temperatures, SMART disk health, services, Docker, or Kubernetes coverage. For Proxmox clusters, keep the cluster API connection for platform inventory and add the agent to each node for host-level augmentation.',
+ 'Pulse Agent is a low-overhead background service. Machines in Pulse are systems with the agent installed and reporting full node-local telemetry such as CPU, memory, disks, network I/O, temperatures, SMART disk health, services, Docker, or Kubernetes coverage. Use Availability checks for ping-only or agentless device monitoring. For Proxmox clusters, keep the cluster API connection for platform inventory and add the agent to each node for host-level augmentation.',
preferredProfile: 'auto',
platforms: ALL_AGENT_PLATFORMS,
},
@@ -64,7 +64,7 @@ const INSTALLER_FOCUS_PRESENTATION: Record<
'Choose the command for the operating system on the machine you want Pulse to monitor.',
recommendationTitle: 'Host install path',
recommendationDetail:
- 'Install Pulse Agent on the machine itself. Pulse will collect host telemetry, services, SMART disk health, sensors, and network metrics from that host after it checks in.',
+ 'Install Pulse Agent on the machine itself. Pulse will collect CPU, memory, disk, network I/O, services, SMART disk health, sensors, and other host telemetry after it checks in. Use Availability checks instead when you only want an agentless reachability probe.',
preferredProfile: 'auto',
platforms: ALL_AGENT_PLATFORMS,
},
@@ -298,7 +298,9 @@ export const InfrastructureInstallerSection: Component<InfrastructureInstallerSe
<ul class="space-y-1 text-xs text-blue-700 dark:text-blue-300">
<li class="flex items-start">
<span class="mr-2 mt-0.5 text-emerald-500">✓</span>
- <span>Pulse Agent on this host reports its own telemetry to this Pulse instance.</span>
+ <span>
+ Pulse Agent on this host reports its own telemetry to this Pulse instance.
+ </span>
</li>
<li class="flex items-start">
<span class="mr-2 mt-0.5 text-emerald-500">✓</span>
@@ -450,9 +452,10 @@ export const InfrastructureInstallerSection: Component<InfrastructureInstallerSe
Installation commands
</h4>
<p class={`mt-0.5 text-xs text-muted ${state.requiresToken() ? 'ml-6' : ''}`}>
- Copy the default command for the first host first, then repeat the install on
- each machine where you want full node-local telemetry. Open advanced options
- only if this machine needs custom connection or install settings.
+ Copy the default command for the first host first. It checks this Pulse URL and
+ the matching agent binary before asking for administrator privileges, then
+ installs Pulse Agent as a background service on each machine where you want full
+ node-local telemetry.
</p>
</div>
</div>
diff --git a/frontend-modern/src/components/Settings/__tests__/InfrastructureOperationsModel.test.tsx b/frontend-modern/src/components/Settings/__tests__/InfrastructureOperationsModel.test.tsx
index 9e5645fcd3..16e4deb8b7 100644
--- a/frontend-modern/src/components/Settings/__tests__/InfrastructureOperationsModel.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/InfrastructureOperationsModel.test.tsx
@@ -243,6 +243,16 @@ describe('infrastructure operations model', () => {
expect(infrastructureInstallerSectionSource).toContain(
'Pulse Agent is a low-overhead background service.',
);
+ expect(infrastructureInstallerSectionSource).toContain(
+ 'Machines in Pulse are systems with the agent installed',
+ );
+ expect(infrastructureInstallerSectionSource).toContain(
+ 'Use Availability checks for ping-only or agentless device monitoring.',
+ );
+ expect(infrastructureInstallerSectionSource).toContain('checks this Pulse URL and');
+ expect(infrastructureInstallerSectionSource).toContain(
+ 'before asking for administrator privileges',
+ );
expect(infrastructureInstallerSectionSource).toContain(
'For Proxmox clusters, keep the cluster API',
);
@@ -264,6 +274,11 @@ describe('infrastructure operations model', () => {
expect(infrastructureInstallerSectionSource).not.toContain(
'Copy disabled until an install token is generated',
);
+ expect(infrastructureOperationsModelSource).toContain(
+ 'preflights this Pulse URL, verifies the matching agent binary is available',
+ );
+ expect(infrastructureOperationsModelSource).toContain('macOS may ask for your');
+ expect(infrastructureOperationsModelSource).toContain('admin password');
});
it('keeps first-host completion handoff on Infrastructure instead of the retired dashboard', async () => {
diff --git a/frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsx b/frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsx
index 35a6a2a8c5..836161a0d7 100644
--- a/frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsx
@@ -314,7 +314,7 @@ describe('InfrastructureWorkspace', () => {
expect(screen.getByText('Proxmox VE').closest('tr')?.className).toContain('grouped-table-row');
expect(screen.queryByText('VMware vCenter')).toBeNull();
expect(screen.queryByText('TrueNAS SCALE')).toBeNull();
- expect(screen.queryByText('Standalone hosts')).toBeNull();
+ expect(screen.queryByText('Pulse Agent hosts')).toBeNull();
expect(screen.getByRole('button', { name: /Add Proxmox VE/i })).toBeInTheDocument();
expect(screen.queryByRole('button', { name: /Add TrueNAS SCALE/i })).toBeNull();
expect(screen.queryByRole('button', { name: /Install Pulse Agent/i })).toBeNull();
@@ -443,7 +443,7 @@ describe('InfrastructureWorkspace', () => {
await waitFor(() => expect(screen.getByText('Proxmox VE')).toBeInTheDocument());
const pveGroup = screen.getByText('Proxmox VE');
- const hostGroup = screen.getByText('Standalone hosts');
+ const hostGroup = screen.getByText('Pulse Agent hosts');
expect(pveGroup.compareDocumentPosition(hostGroup) & Node.DOCUMENT_POSITION_FOLLOWING).toBe(
Node.DOCUMENT_POSITION_FOLLOWING,
);
@@ -489,7 +489,7 @@ describe('InfrastructureWorkspace', () => {
expect(
screen.getByText(/VMware vCenter is available as a preview platform/i),
).toBeInTheDocument();
- expect(screen.getByText(/standalone hosts through Pulse Agent/i)).toBeInTheDocument();
+ expect(screen.getByText(/Pulse Agent hosts/i)).toBeInTheDocument();
});
it('routes discovery actions from the manager and shows discovered candidates in the matching platform group', async () => {
@@ -798,7 +798,7 @@ describe('InfrastructureWorkspace', () => {
renderWorkspace();
await waitFor(() => expect(screen.getByText('Unraid')).toBeInTheDocument());
- expect(screen.queryByText('Standalone hosts')).toBeNull();
+ expect(screen.queryByText('Pulse Agent hosts')).toBeNull();
expect(screen.getByText('Tower')).toBeInTheDocument();
expect(screen.getByText('Unraid 7.1.0')).toBeInTheDocument();
expect(screen.getByText('192.168.0.10')).toBeInTheDocument();
@@ -1006,7 +1006,7 @@ describe('InfrastructureWorkspace', () => {
expect(screen.queryByText('Config pending')).toBeNull();
expect(screen.queryByText('Rollout pending')).toBeNull();
expect(screen.getAllByText('Host telemetry').length).toBeGreaterThan(0);
- expect(screen.queryByText('Standalone hosts')).toBeNull();
+ expect(screen.queryByText('Pulse Agent hosts')).toBeNull();
expect(screen.getAllByText('delly')).toHaveLength(1);
expect(screen.getAllByText('minipc')).toHaveLength(1);
});
diff --git a/frontend-modern/src/components/Settings/infrastructureOperationsModel.tsx b/frontend-modern/src/components/Settings/infrastructureOperationsModel.tsx
index 25fe246b5e..86afd613ed 100644
--- a/frontend-modern/src/components/Settings/infrastructureOperationsModel.tsx
+++ b/frontend-modern/src/components/Settings/infrastructureOperationsModel.tsx
@@ -338,7 +338,7 @@ export const buildCommandsByPlatform = (
linux: {
title: 'Install on Linux',
description:
- 'The unified installer downloads the agent binary and configures the appropriate service for your system.',
+ 'The unified installer preflights this Pulse URL, verifies the matching agent binary is available, and configures the appropriate service for your system.',
snippets: [
{
label: 'Install',
@@ -356,16 +356,16 @@ export const buildCommandsByPlatform = (
macos: {
title: 'Install on macOS',
description:
- 'The unified installer downloads the universal binary and sets up a launchd service for background monitoring.',
+ 'The unified installer preflights this Pulse URL, verifies the matching agent binary is available, and sets up a launchd service for background monitoring.',
snippets: [
{
label: 'Install with launchd',
command: unixCommand,
note: (
<span>
- Command auto-escalates with <code>sudo</code> when available; otherwise run from a root
- shell. Creates <code>/Library/LaunchDaemons/com.pulse.agent.plist</code> and starts the
- agent automatically.
+ Command auto-escalates with <code>sudo</code> when available, so macOS may ask for your
+ admin password. Creates <code>/Library/LaunchDaemons/com.pulse.agent.plist</code> and
+ starts the agent automatically.
</span>
),
},
diff --git a/frontend-modern/src/utils/__tests__/agentInstallCommand.test.ts b/frontend-modern/src/utils/__tests__/agentInstallCommand.test.ts
index ec076939c9..fd74a6d7b9 100644
--- a/frontend-modern/src/utils/__tests__/agentInstallCommand.test.ts
+++ b/frontend-modern/src/utils/__tests__/agentInstallCommand.test.ts
@@ -15,19 +15,42 @@ describe('agentInstallCommand', () => {
});
expect(command).toContain("--url 'http://pulse.example:7655'");
- expect(command).toContain("--token 'token-123'");
+ expect(command).toContain('printf %s \'token-123\' > "$token_file"');
+ expect(command).toContain('--token-file "$token_file"');
expect(command).toContain('--insecure');
});
- it('shell-quotes canonical URL and token transport', () => {
+ it('shell-quotes canonical URL and token-file bootstrap transport', () => {
const command = buildUnixAgentInstallCommand({
baseUrl: "https://pulse.example/base path/agent's",
token: "tok'en",
});
- expect(command).toContain("curl -fsSL 'https://pulse.example/base path/agent'\"'\"'s/install.sh'");
+ expect(command).toContain(
+ "curl -fsSL 'https://pulse.example/base path/agent'\"'\"'s/install.sh' -o \"$install_script\"",
+ );
expect(command).toContain("--url 'https://pulse.example/base path/agent'\"'\"'s'");
- expect(command).toContain("--token 'tok'\"'\"'en'");
+ expect(command).toContain("printf %s 'tok'\"'\"'en' > \"$token_file\"");
+ expect(command).toContain('--token-file "$token_file"');
+ expect(command).not.toContain("--token 'tok");
+ });
+
+ it('runs a non-root preflight before privilege escalation for Unix installs', () => {
+ const command = buildUnixAgentInstallCommand({
+ baseUrl: 'https://pulse.example',
+ token: 'token-123',
+ });
+
+ const preflightIndex = command.indexOf('--preflight-only');
+ const sudoIndex = command.indexOf('sudo bash "$install_script"');
+
+ expect(command).toContain('tmp_dir=$(mktemp -d)');
+ expect(command).toContain('trap \'rm -rf "$tmp_dir"\' EXIT');
+ expect(command).toContain('bash "$install_script" --url');
+ expect(command).toContain('--output json');
+ expect(command).toContain('--non-interactive');
+ expect(preflightIndex).toBeGreaterThan(-1);
+ expect(sudoIndex).toBeGreaterThan(preflightIndex);
});
it('normalizes trailing slashes before building installer transport', () => {
@@ -59,9 +82,11 @@ describe('agentInstallCommand', () => {
caCertPath: '/etc/pulse/custom-ca.pem',
});
- expect(command).toContain("curl -fsSL --cacert '/etc/pulse/custom-ca.pem' 'https://pulse.example/install.sh'");
+ expect(command).toContain(
+ "curl -fsSL --cacert '/etc/pulse/custom-ca.pem' 'https://pulse.example/install.sh' -o \"$install_script\"",
+ );
expect(command).toContain("--url 'https://pulse.example'");
- expect(command).toContain("--token 'token-123'");
+ expect(command).toContain('--token-file "$token_file"');
expect(command).toContain("--cacert '/etc/pulse/custom-ca.pem'");
});
@@ -72,9 +97,11 @@ describe('agentInstallCommand', () => {
insecure: true,
});
- expect(command).toContain("curl -kfsSL 'https://pulse.example/install.sh'");
+ expect(command).toContain(
+ 'curl -kfsSL \'https://pulse.example/install.sh\' -o "$install_script"',
+ );
expect(command).toContain("--url 'https://pulse.example'");
- expect(command).toContain("--token 'token-123'");
+ expect(command).toContain('--token-file "$token_file"');
expect(command).toContain('--insecure');
});
@@ -84,9 +111,12 @@ describe('agentInstallCommand', () => {
token: null,
});
- expect(command).toContain("curl -fsSL 'https://pulse.example/install.sh'");
+ expect(command).toContain(
+ 'curl -fsSL \'https://pulse.example/install.sh\' -o "$install_script"',
+ );
expect(command).toContain("--url 'https://pulse.example'");
expect(command).not.toContain('--token');
+ expect(command).not.toContain('token_file=');
});
it('builds shared Windows install transport with token, insecure TLS, and custom CA continuity', () => {
@@ -138,8 +168,8 @@ describe('agentInstallCommand', () => {
extraArgs: ['--enable-docker', '--disable-host', '--enable-commands'],
});
- expect(command).toContain("--token 'token-123'");
- expect(command).toContain('--enable-docker --disable-host --enable-commands');
+ expect(command).toContain('--token-file "$token_file"');
+ expect(command).toContain('--enable-docker \\\n --disable-host \\\n --enable-commands');
});
it('preserves extra env assignments for shared Windows install transport', () => {
diff --git a/frontend-modern/src/utils/__tests__/infrastructureOnboardingPresentation.test.ts b/frontend-modern/src/utils/__tests__/infrastructureOnboardingPresentation.test.ts
index 9ee3afd49a..a3dbd45337 100644
--- a/frontend-modern/src/utils/__tests__/infrastructureOnboardingPresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/infrastructureOnboardingPresentation.test.ts
@@ -128,7 +128,7 @@ describe('infrastructureOnboardingPresentation', () => {
}),
expect.objectContaining({
type: 'agent',
- label: 'Standalone hosts',
+ label: 'Pulse Agent hosts',
actionLabel: 'Install Pulse Agent',
}),
]);
@@ -215,7 +215,7 @@ describe('infrastructureOnboardingPresentation', () => {
expect(getInfrastructureEmptyStateDetail()).toContain(
'VMware vCenter is available as a preview platform',
);
- expect(getInfrastructureEmptyStateDetail()).toContain('standalone hosts through Pulse Agent');
+ expect(getInfrastructureEmptyStateDetail()).toContain('Pulse Agent hosts');
expect(getInfrastructureEmptyStateDetail()).toContain('Docker and Kubernetes are discovered');
expect(getInfrastructureEmptyStateDetail()).not.toContain('network endpoints');
});
diff --git a/frontend-modern/src/utils/agentInstallCommand.ts b/frontend-modern/src/utils/agentInstallCommand.ts
index 18090a153c..a1f7b327d7 100644
--- a/frontend-modern/src/utils/agentInstallCommand.ts
+++ b/frontend-modern/src/utils/agentInstallCommand.ts
@@ -2,13 +2,6 @@ const shellQuoteArg = (value: string) => `'${value.replace(/'/g, `'\"'\"'`)}'`;
export const powerShellQuote = (value: string) =>
value.replace(/`/g, '``').replace(/"/g, '`"').replace(/\$/g, '`$');
-const withPrivilegeEscalation = (command: string) => {
- if (!command.includes('| bash -s --')) return command;
- return command.replace(/\|\s*bash -s --([\s\S]*)$/, (_match, args: string) => {
- return `| { if [ "$(id -u)" -eq 0 ]; then bash -s --${args}; elif command -v sudo >/dev/null 2>&1; then sudo bash -s --${args}; else echo "Root privileges required. Run as root (su -) and retry." >&2; exit 1; fi; }`;
- });
-};
-
export const normalizeInstallerBaseUrl = (baseUrl: string) => baseUrl.replace(/\/+$/, '');
export const resolveInstallerBaseUrl = (customBaseUrl: string, fallbackBaseUrl: string) => {
@@ -48,28 +41,50 @@ export const buildUnixAgentInstallCommand = ({
}
const normalizedCaCertPath = (caCertPath || '').trim();
const normalizedToken = (token || '').trim();
- const normalizedExtraArgs = extraArgs
- .map((arg) => arg.trim())
- .filter((arg) => arg.length > 0)
- .join(' ');
- const curlFlags = insecure ? ' -kfsSL' : ' -fsSL';
- let command =
- `curl${curlFlags}${normalizedCaCertPath ? ` --cacert ${shellQuoteArg(normalizedCaCertPath)}` : ''} ${shellQuoteArg(`${normalizedBaseUrl}/install.sh`)} | bash -s -- --url ${shellQuoteArg(normalizedBaseUrl)}` +
- `${normalizedToken ? ` --token ${shellQuoteArg(normalizedToken)}` : ''}`;
-
- if (normalizedExtraArgs) {
- command += ` ${normalizedExtraArgs}`;
- }
+ const normalizedExtraArgs = extraArgs.map((arg) => arg.trim()).filter((arg) => arg.length > 0);
+ const installRequiresInsecure = insecure || normalizedBaseUrl.startsWith('http://');
+ const curlFlags = insecure ? '-kfsSL' : '-fsSL';
+ const caCertArg = normalizedCaCertPath
+ ? ` \\\n --cacert ${shellQuoteArg(normalizedCaCertPath)}`
+ : '';
+ const insecureArg = installRequiresInsecure ? ` \\\n --insecure` : '';
+ const preflightArgs = [
+ `--url ${shellQuoteArg(normalizedBaseUrl)}`,
+ '--preflight-only',
+ '--output json',
+ '--non-interactive',
+ ].join(' \\\n ');
+ const installArgs = [
+ `--url ${shellQuoteArg(normalizedBaseUrl)}`,
+ ...(normalizedToken ? ['--token-file "$token_file"'] : []),
+ ...normalizedExtraArgs,
+ '--non-interactive',
+ ].join(' \\\n ');
- if (normalizedCaCertPath) {
- command += ` --cacert ${shellQuoteArg(normalizedCaCertPath)}`;
- }
-
- if (insecure || normalizedBaseUrl.startsWith('http://')) {
- command += ' --insecure';
+ return `(
+ set -e
+ tmp_dir=$(mktemp -d)
+ install_script="$tmp_dir/install.sh"
+ trap 'rm -rf "$tmp_dir"' EXIT
+ curl ${curlFlags}${normalizedCaCertPath ? ` --cacert ${shellQuoteArg(normalizedCaCertPath)}` : ''} ${shellQuoteArg(`${normalizedBaseUrl}/install.sh`)} -o "$install_script"
+ chmod +x "$install_script"${
+ normalizedToken
+ ? `
+ token_file="$tmp_dir/token"
+ umask 077
+ printf %s ${shellQuoteArg(normalizedToken)} > "$token_file"`
+ : ''
}
-
- return withPrivilegeEscalation(command);
+ bash "$install_script" ${preflightArgs}${caCertArg}${insecureArg}
+ if [ "$(id -u)" -eq 0 ]; then
+ bash "$install_script" ${installArgs}${caCertArg}${insecureArg}
+ elif command -v sudo >/dev/null 2>&1; then
+ sudo bash "$install_script" ${installArgs}${caCertArg}${insecureArg}
+ else
+ echo "Root privileges required. Run as root (su -) and retry." >&2
+ exit 1
+ fi
+)`;
};
export const buildPowerShellInstallScriptBootstrap = (baseUrl: string) => {
diff --git a/frontend-modern/src/utils/infrastructureOnboardingPresentation.ts b/frontend-modern/src/utils/infrastructureOnboardingPresentation.ts
index 4e74988f47..f906777bd1 100644
--- a/frontend-modern/src/utils/infrastructureOnboardingPresentation.ts
+++ b/frontend-modern/src/utils/infrastructureOnboardingPresentation.ts
@@ -294,7 +294,7 @@ const AGENT_CATALOG_ITEMS: Record<
'linux-host': {
routeStep: 'linux-host',
label: 'Linux, macOS, Windows host',
- bestFor: 'Standalone machines where you want low-overhead node-local telemetry.',
+ bestFor: 'Machines where you want low-overhead node-local telemetry from Pulse Agent.',
coverage: 'Host telemetry, services, SMART, sensors, network metrics, and remote update state',
catalogDescription: 'Machine telemetry, services, SMART, sensors',
searchAliases: ['host', 'server', 'machine', 'node', 'ubuntu', 'debian', 'freebsd', 'windows'],
@@ -380,7 +380,7 @@ const SOURCE_MANAGER_LABEL_OVERRIDES: Partial<
>
> = {
agent: {
- label: 'Standalone hosts',
+ label: 'Pulse Agent hosts',
actionLabel: 'Install Pulse Agent',
},
};
@@ -552,7 +552,7 @@ export const getInfrastructureEmptyStateSummary = (): string =>
'Choose an infrastructure source to start monitoring your environment.';
export const getInfrastructureEmptyStateDetail = (): string =>
- 'Supported source types include TrueNAS SCALE, Proxmox VE, Proxmox Backup Server, Proxmox Mail Gateway, and standalone hosts through Pulse Agent. VMware vCenter is available as a preview platform pending live support proof. Docker and Kubernetes are discovered from supported agent hosts.';
+ 'Supported source types include TrueNAS SCALE, Proxmox VE, Proxmox Backup Server, Proxmox Mail Gateway, and Pulse Agent hosts. VMware vCenter is available as a preview platform pending live support proof. Docker and Kubernetes are discovered from supported agent hosts.';
export const getInfrastructureCoverageCompleteActionPresentation =
(): InfrastructureCoverageCompleteActionPresentation => ({
diff --git a/internal/api/unified_agent.go b/internal/api/unified_agent.go
index fe4d31f171..8b5e0da780 100644
--- a/internal/api/unified_agent.go
+++ b/internal/api/unified_agent.go
@@ -125,6 +125,27 @@ func normalizeUnifiedAgentArch(arch string) string {
}
}
+func unifiedAgentLocalBuildCommand(normalized string) string {
+ goos, goarch, ok := strings.Cut(strings.TrimSpace(normalized), "-")
+ if !ok || goos == "" || goarch == "" {
+ goos = "linux"
+ goarch = "amd64"
+ normalized = "linux-amd64"
+ }
+
+ env := []string{"CGO_ENABLED=0", "GOOS=" + goos}
+ switch goarch {
+ case "armv7":
+ env = append(env, "GOARCH=arm", "GOARM=7")
+ case "armv6":
+ env = append(env, "GOARCH=arm", "GOARM=6")
+ default:
+ env = append(env, "GOARCH="+goarch)
+ }
+
+ return fmt.Sprintf("%s go build -o bin/pulse-agent-%s ./cmd/pulse-agent", strings.Join(env, " "), normalized)
+}
+
// handleDownloadUnifiedAgent serves the pulse-agent binary
func (r *Router) handleDownloadUnifiedAgent(w http.ResponseWriter, req *http.Request) {
if req.Method != http.MethodGet && req.Method != http.MethodHead {
@@ -237,7 +258,7 @@ func (r *Router) handleDownloadUnifiedAgent(w http.ResponseWriter, req *http.Req
strings.Join(invalidCandidates, "\n "),
)
}
- http.Error(w, reason+"\nBuild with:\n GOOS=linux GOARCH=amd64 go build -o bin/pulse-agent-linux-amd64 ./cmd/pulse-agent", http.StatusNotFound)
+ http.Error(w, reason+"\nBuild with:\n "+unifiedAgentLocalBuildCommand(normalized), http.StatusNotFound)
return
}
r.proxyAgentBinaryFromGitHub(w, req, normalized)
diff --git a/internal/api/unified_agent_test.go b/internal/api/unified_agent_test.go
index bc931d730c..7aabbe5b0d 100644
--- a/internal/api/unified_agent_test.go
+++ b/internal/api/unified_agent_test.go
@@ -462,6 +462,35 @@ func TestDownloadUnifiedAgent_DevPrereleaseRejectsGitHubFallback(t *testing.T) {
assert.Contains(t, w.Body.String(), "go build -o bin/pulse-agent-linux-amd64")
}
+func TestDownloadUnifiedAgent_DevModeReportsRequestedLocalBuildCommand(t *testing.T) {
+ router, _ := setupUnifiedAgentRouter(t)
+ router.serverVersion = "dev"
+
+ req := httptest.NewRequest(http.MethodGet, "/api/install/agent?arch=darwin-arm64", nil)
+ w := httptest.NewRecorder()
+
+ router.handleDownloadUnifiedAgent(w, req)
+
+ require.Equal(t, http.StatusNotFound, w.Code)
+ assert.Contains(t, w.Body.String(), "Agent binary not found for \"darwin-arm64\" in dev mode.")
+ assert.Contains(t, w.Body.String(), "CGO_ENABLED=0 GOOS=darwin GOARCH=arm64")
+ assert.Contains(t, w.Body.String(), "go build -o bin/pulse-agent-darwin-arm64 ./cmd/pulse-agent")
+ assert.NotContains(t, w.Body.String(), "bin/pulse-agent-linux-amd64")
+}
+
+func TestUnifiedAgentLocalBuildCommandHandlesArmVariants(t *testing.T) {
+ assert.Equal(
+ t,
+ "CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -o bin/pulse-agent-linux-armv7 ./cmd/pulse-agent",
+ unifiedAgentLocalBuildCommand("linux-armv7"),
+ )
+ assert.Equal(
+ t,
+ "CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -o bin/pulse-agent-linux-armv6 ./cmd/pulse-agent",
+ unifiedAgentLocalBuildCommand("linux-armv6"),
+ )
+}
+
func TestNormalizeUnifiedAgentArch(t *testing.T) {
tests := []struct {
input string
diff --git a/scripts/install.sh b/scripts/install.sh
index e4125c3d8c..7989f59479 100755
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -1278,6 +1278,32 @@ build_exec_args_array() {
EXEC_ARGS_ARRAY=("${EXEC_ARG_ITEMS[@]}")
}
+xml_escape() {
+ local value="$1"
+ value="${value//&/&amp;}"
+ value="${value//</&lt;}"
+ value="${value//>/&gt;}"
+ printf '%s' "$value"
+}
+
+append_plist_arg() {
+ local arg="$1"
+ PLIST_ARGS="${PLIST_ARGS}
+ <string>$(xml_escape "$arg")</string>"
+}
+
+build_plist_program_arguments() {
+ local executable="$1"
+ PLIST_ARGS=""
+ append_plist_arg "$executable"
+ build_exec_arg_items "true"
+
+ local arg=""
+ for arg in ${EXEC_ARG_ITEMS[@]+"${EXEC_ARG_ITEMS[@]}"}; do
+ append_plist_arg "$arg"
+ done
+}
+
ensure_runtime_token_file() {
local state_dir="${1:-$STATE_DIR}"
local token_file="${state_dir}/token"
@@ -1502,7 +1528,7 @@ if [[ -n "$PROXMOX_TYPE" && "$PROXMOX_TYPE" != "pve" && "$PROXMOX_TYPE" != "pbs"
fi
# --- Check Root ---
-if [[ $EUID -ne 0 ]]; then
+if [[ $EUID -ne 0 && "$PREFLIGHT_ONLY" != "true" ]]; then
echo "This script must be run as root. Please use sudo."
exit 1
fi
@@ -1872,7 +1898,8 @@ if [[ "$PREFLIGHT_ONLY" == "true" ]]; then
i386|i686) PF_ARCH="386" ;;
*) fail "Unsupported architecture: $PF_ARCH" "$EXIT_UNSUPPORTED_ARCH" ;;
esac
- json_event "preflight" "arch_ok" "Architecture: ${PF_OS}-${PF_ARCH}"
+ PF_ARCH_PARAM="${PF_OS}-${PF_ARCH}"
+ json_event "preflight" "arch_ok" "Architecture: ${PF_ARCH_PARAM}"
# Check 2: Existing agent
AGENT_STATUS="not_installed"
@@ -1883,7 +1910,7 @@ if [[ "$PREFLIGHT_ONLY" == "true" ]]; then
fi
json_event "preflight" "$AGENT_STATUS" "Agent status: ${AGENT_STATUS}"
- # Check 3: Pulse URL reachability
+ # Check 3: Pulse URL reachability and agent binary availability
PREFLIGHT_EXIT="$EXIT_OK"
if [[ -n "$PULSE_URL" ]]; then
CURL_TEST_ARGS=(-sf --connect-timeout 5 -o /dev/null)
@@ -1895,6 +1922,26 @@ if [[ "$PREFLIGHT_ONLY" == "true" ]]; then
json_event "preflight" "pulse_unreachable" "Pulse URL not reachable" "$EXIT_PREFLIGHT_FAILED"
PREFLIGHT_EXIT="$EXIT_PREFLIGHT_FAILED"
fi
+
+ PREFLIGHT_HEADERS=$(mktemp)
+ TMP_FILES+=("$PREFLIGHT_HEADERS")
+ CURL_DOWNLOAD_CHECK_ARGS=(-fsSI --connect-timeout 5 --max-time 30 -D "$PREFLIGHT_HEADERS" -o /dev/null)
+ if [[ "$INSECURE" == "true" ]]; then CURL_DOWNLOAD_CHECK_ARGS+=(-k); fi
+ if [[ -n "$CURL_CA_BUNDLE" ]]; then CURL_DOWNLOAD_CHECK_ARGS+=(--cacert "$CURL_CA_BUNDLE"); fi
+
+ DOWNLOAD_CHECK_URL="${PULSE_URL}/download/${BINARY_NAME}?arch=${PF_ARCH_PARAM}"
+ if curl "${CURL_DOWNLOAD_CHECK_ARGS[@]}" "$DOWNLOAD_CHECK_URL"; then
+ PREFLIGHT_EXPECTED_SHA=$(grep -i '^X-Checksum-Sha256:' "$PREFLIGHT_HEADERS" 2>/dev/null | tr -d '\r' | awk '{print $2}' || true)
+ if [[ -n "$PREFLIGHT_EXPECTED_SHA" ]]; then
+ json_event "preflight" "agent_download_available" "Agent binary available for ${PF_ARCH_PARAM}"
+ else
+ json_event "preflight" "agent_download_checksum_missing" "Agent binary download did not include checksum header" "$EXIT_CHECKSUM_FAILED"
+ PREFLIGHT_EXIT="$EXIT_CHECKSUM_FAILED"
+ fi
+ else
+ json_event "preflight" "agent_download_unavailable" "Agent binary unavailable for ${PF_ARCH_PARAM}" "$EXIT_DOWNLOAD_FAILED"
+ PREFLIGHT_EXIT="$EXIT_DOWNLOAD_FAILED"
+ fi
fi
# Output summary
@@ -1903,14 +1950,14 @@ if [[ "$PREFLIGHT_ONLY" == "true" ]]; then
printf '{"phase":"preflight_complete","code":"ok","message":"Preflight checks passed","exitCode":0,"data":{"arch":"%s-%s","agent_status":"%s"}}\n' \
"$PF_OS" "$PF_ARCH" "$AGENT_STATUS"
else
- log_info "Preflight checks passed (arch: ${PF_OS}-${PF_ARCH}, agent: ${AGENT_STATUS})"
+ log_info "Preflight checks passed (arch: ${PF_ARCH_PARAM}, agent: ${AGENT_STATUS})"
fi
else
if [[ "$OUTPUT_FORMAT" == "json" ]]; then
printf '{"phase":"preflight_complete","code":"failed","message":"Preflight checks failed","exitCode":%d,"data":{"arch":"%s-%s","agent_status":"%s"}}\n' \
"$PREFLIGHT_EXIT" "$PF_OS" "$PF_ARCH" "$AGENT_STATUS"
else
- log_error "Preflight checks failed (arch: ${PF_OS}-${PF_ARCH}, agent: ${AGENT_STATUS})"
+ log_error "Preflight checks failed (arch: ${PF_ARCH_PARAM}, agent: ${AGENT_STATUS})"
fi
fi
exit "$PREFLIGHT_EXIT"
@@ -2043,83 +2090,16 @@ if [[ "$OS" == "darwin" ]]; then
ensure_runtime_token_file "$STATE_DIR"
clear_proxmox_state_if_needed
- # Build program arguments array
- PLIST_ARGS=" <string>${INSTALL_DIR}/${BINARY_NAME}</string>
- <string>--url</string>
- <string>${PULSE_URL}</string>
- <string>--interval</string>
- <string>${INTERVAL}</string>"
- if [[ -n "$RUNTIME_TOKEN_FILE" ]]; then
- PLIST_ARGS="${PLIST_ARGS}
- <string>--token-file</string>
- <string>${RUNTIME_TOKEN_FILE}</string>"
- fi
-
- # Always pass enable-host flag since agent defaults to true
- if [[ "$ENABLE_HOST" == "true" ]]; then
- PLIST_ARGS="${PLIST_ARGS}
- <string>--enable-host</string>"
- else
- PLIST_ARGS="${PLIST_ARGS}
- <string>--enable-host=false</string>"
- fi
- if [[ "$ENABLE_DOCKER" == "true" ]]; then
- PLIST_ARGS="${PLIST_ARGS}
- <string>--enable-docker</string>"
- fi
- if [[ "$ENABLE_KUBERNETES" == "true" ]]; then
- PLIST_ARGS="${PLIST_ARGS}
- <string>--enable-kubernetes</string>"
- fi
- if [[ -n "$KUBECONFIG_PATH" ]]; then
- PLIST_ARGS="${PLIST_ARGS}
- <string>--kubeconfig</string>
- <string>${KUBECONFIG_PATH}</string>"
- fi
- if [[ "$KUBE_INCLUDE_ALL_PODS" == "true" ]]; then
- PLIST_ARGS="${PLIST_ARGS}
- <string>--kube-include-all-pods</string>"
- fi
- if [[ "$KUBE_INCLUDE_ALL_DEPLOYMENTS" == "true" ]]; then
- PLIST_ARGS="${PLIST_ARGS}
- <string>--kube-include-all-deployments</string>"
- fi
- if [[ "$INSECURE" == "true" ]]; then
- PLIST_ARGS="${PLIST_ARGS}
- <string>--insecure</string>"
- fi
- if [[ "$ENABLE_COMMANDS" == "true" ]]; then
- PLIST_ARGS="${PLIST_ARGS}
- <string>--enable-commands</string>"
- fi
- if [[ "$ENROLL" == "true" ]]; then
- PLIST_ARGS="${PLIST_ARGS}
- <string>--enroll</string>"
- fi
- if [[ -n "$AGENT_ID" ]]; then
- PLIST_ARGS="${PLIST_ARGS}
- <string>--agent-id</string>
- <string>${AGENT_ID}</string>"
- fi
- if [[ -n "$STATE_DIR" ]]; then
- PLIST_ARGS="${PLIST_ARGS}
- <string>--state-dir</string>
- <string>${STATE_DIR}</string>"
- fi
- # Add disk exclude patterns (use ${arr[@]+"${arr[@]}"} for bash 3.2 compatibility with set -u)
- for pattern in ${DISK_EXCLUDES[@]+"${DISK_EXCLUDES[@]}"}; do
- PLIST_ARGS="${PLIST_ARGS}
- <string>--disk-exclude</string>
- <string>${pattern}</string>"
- done
+ build_plist_program_arguments "${INSTALL_DIR}/${BINARY_NAME}"
PLIST_ENV=""
if [[ -n "$SSL_CERT_ENV_NAME" ]]; then
+ PLIST_SSL_CERT_ENV_VALUE=$(xml_escape "$SSL_CERT_ENV_VALUE")
PLIST_ENV="
<key>EnvironmentVariables</key>
<dict>
<key>${SSL_CERT_ENV_NAME}</key>
- <string>${SSL_CERT_ENV_VALUE}</string>
+ <string>${PLIST_SSL_CERT_ENV_VALUE}</string>
</dict>"
fi
diff --git a/scripts/installtests/install_sh_test.go b/scripts/installtests/install_sh_test.go
index 99313b75be..6a66d10d18 100644
--- a/scripts/installtests/install_sh_test.go
+++ b/scripts/installtests/install_sh_test.go
@@ -100,6 +100,136 @@ func TestInstallSHAgentServiceSecurityDefaults(t *testing.T) {
}
}
+func TestInstallSHPreflightChecksAgentDownloadArtifact(t *testing.T) {
+ var requestedDownloadPath string
+ var requestedDownloadArch string
+ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ switch r.URL.Path {
+ case "/api/health":
+ w.WriteHeader(http.StatusOK)
+ case "/download/pulse-agent":
+ requestedDownloadPath = r.URL.Path
+ requestedDownloadArch = r.URL.Query().Get("arch")
+ w.Header().Set("X-Checksum-Sha256", strings.Repeat("a", 64))
+ w.WriteHeader(http.StatusOK)
+ default:
+ http.NotFound(w, r)
+ }
+ }))
+ defer server.Close()
+
+ cmd := exec.Command(
+ "bash",
+ repoFile("scripts", "install.sh"),
+ "--url",
+ server.URL,
+ "--preflight-only",
+ "--output",
+ "json",
+ "--non-interactive",
+ )
+ out, err := cmd.CombinedOutput()
+ if err != nil {
+ t.Fatalf("preflight failed: %v\n%s", err, out)
+ }
+
+ got := string(out)
+ if !strings.Contains(got, `"code":"agent_download_available"`) {
+ t.Fatalf("preflight did not report agent download availability:\n%s", got)
+ }
+ if requestedDownloadPath != "/download/pulse-agent" {
+ t.Fatalf("download path = %q, want /download/pulse-agent", requestedDownloadPath)
+ }
+ if requestedDownloadArch == "" {
+ t.Fatalf("download arch query was empty")
+ }
+}
+
+func TestInstallSHPreflightDoesNotRequireRoot(t *testing.T) {
+ content, err := os.ReadFile(repoFile("scripts", "install.sh"))
+ if err != nil {
+ t.Fatalf("read install.sh: %v", err)
+ }
+
+ script := string(content)
+ required := []string{
+ `if [[ $EUID -ne 0 && "$PREFLIGHT_ONLY" != "true" ]]; then`,
+ `DOWNLOAD_CHECK_URL="${PULSE_URL}/download/${BINARY_NAME}?arch=${PF_ARCH_PARAM}"`,
+ `CURL_DOWNLOAD_CHECK_ARGS=(-fsSI --connect-timeout 5 --max-time 30 -D "$PREFLIGHT_HEADERS" -o /dev/null)`,
+ `grep -i '^X-Checksum-Sha256:' "$PREFLIGHT_HEADERS"`,
+ `"agent_download_available"`,
+ `"agent_download_unavailable"`,
+ `"agent_download_checksum_missing"`,
+ }
+ for _, needle := range required {
+ if !strings.Contains(script, needle) {
+ t.Fatalf("install.sh missing non-root preflight download check: %s", needle)
+ }
+ }
+}
+
+func TestBuildPlistProgramArgumentsUsesSharedExecArgs(t *testing.T) {
+ script := `
+` + extractInstallShellFunction(t, "build_exec_arg_items") + `
+` + extractInstallShellFunction(t, "xml_escape") + `
+` + extractInstallShellFunction(t, "append_plist_arg") + `
+` + extractInstallShellFunction(t, "build_plist_program_arguments") + `
+ PULSE_URL="https://pulse.example/a&b"
+ PULSE_TOKEN="deadbeef"
+ INTERVAL="30s"
+ ENABLE_HOST="true"
+ ENABLE_DOCKER="false"
+ DOCKER_EXPLICIT="true"
+ ENABLE_KUBERNETES="true"
+ KUBECONFIG_PATH="/etc/kube config"
+ ENABLE_PROXMOX="true"
+ PROXMOX_TYPE="pbs"
+ INSECURE="true"
+ RUNTIME_TOKEN_FILE="/var/lib/pulse-agent/token"
+ ENABLE_COMMANDS="true"
+ HEALTH_ADDR_SET="true"
+ HEALTH_ADDR=""
+ ENROLL="true"
+ KUBE_INCLUDE_ALL_PODS="true"
+ KUBE_INCLUDE_ALL_DEPLOYMENTS="true"
+ AGENT_ID="agent-1"
+ HOSTNAME_OVERRIDE="Richard's Mac & Mini"
+ STATE_DIR="/var/lib/pulse-agent"
+ DISK_EXCLUDES=("Time Machine")
+ build_plist_program_arguments "/usr/local/bin/pulse-agent"
+ printf '%s\n' "$PLIST_ARGS"
+ `
+
+ out, err := exec.Command("bash", "-c", script).CombinedOutput()
+ if err != nil {
+ t.Fatalf("bash: %v\n%s", err, out)
+ }
+ got := string(out)
+ required := []string{
+ `<string>/usr/local/bin/pulse-agent</string>`,
+ `<string>https://pulse.example/a&amp;b</string>`,
+ `<string>--token-file</string>`,
+ `<string>/var/lib/pulse-agent/token</string>`,
+ `<string>--enable-docker=false</string>`,
+ `<string>--enable-proxmox</string>`,
+ `<string>--proxmox-type</string>`,
+ `<string>pbs</string>`,
+ `<string>--health-addr</string>`,
+ `<string>--hostname</string>`,
+ `<string>Richard's Mac &amp; Mini</string>`,
+ `<string>--disk-exclude</string>`,
+ `<string>Time Machine</string>`,
+ }
+ for _, needle := range required {
+ if !strings.Contains(got, needle) {
+ t.Fatalf("plist args missing %s:\n%s", needle, got)
+ }
+ }
+ if strings.Contains(got, "--token</string>") || strings.Contains(got, "deadbeef") {
+ t.Fatalf("plist args leaked raw token:\n%s", got)
+ }
+}
+
// TestConnectionEnvRecovery verifies the canonical helper logic that parses
// connection.env without using shell source (to prevent injection).
func TestConnectionEnvRecovery(t *testing.T) {