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.

Keep the copied Windows install command on one line

rcourtman9715ce8a331c
diff --git a/frontend-modern/src/utils/__tests__/agentInstallCommand.test.ts b/frontend-modern/src/utils/__tests__/agentInstallCommand.test.ts
index 43b0bd0892..cc208d19b7 100644
--- a/frontend-modern/src/utils/__tests__/agentInstallCommand.test.ts
+++ b/frontend-modern/src/utils/__tests__/agentInstallCommand.test.ts
@@ -119,6 +119,27 @@ describe('agentInstallCommand', () => {
expect(command).not.toContain('token_file=');
});
+ it('keeps every copied Windows command on a single line', () => {
+ // Console hosts execute pasted input line by line, so a literal newline
+ // anywhere in the copied command breaks it in PowerShell 5.1 and 7 alike.
+ const variants = [
+ buildWindowsAgentInstallCommand({ baseUrl: 'https://pulse.example' }),
+ buildWindowsAgentInstallCommand({
+ baseUrl: 'https://pulse.example',
+ token: 'token-123',
+ insecure: true,
+ }),
+ buildWindowsAgentInstallCommand({
+ baseUrl: 'https://pulse.example',
+ token: 'token-123',
+ caCertPath: 'C:\\Pulse\\custom-ca.cer',
+ }),
+ ];
+ for (const command of variants) {
+ expect(command).not.toMatch(/[\r\n]/);
+ }
+ });
+
it('builds shared Windows install transport with token, insecure TLS, and custom CA continuity', () => {
const command = buildWindowsAgentInstallCommand({
baseUrl: 'https://pulse.example/base/',
diff --git a/frontend-modern/src/utils/agentInstallCommand.ts b/frontend-modern/src/utils/agentInstallCommand.ts
index 588be09d17..99b4fd46ea 100644
--- a/frontend-modern/src/utils/agentInstallCommand.ts
+++ b/frontend-modern/src/utils/agentInstallCommand.ts
@@ -64,9 +64,19 @@ public static class PulseInstallerCertificateValidator
}
}`.trim();
+// The copied command is pasted into a console, and console hosts execute
+// pasted input line by line, so any literal newline inside the command breaks
+// it in both Windows PowerShell 5.1 and PowerShell 7. C# is whitespace
+// insensitive (and the source carries no line comments), so the type
+// definition collapses onto the command's single line.
+const powerShellTlsValidatorInlineSource = powerShellTlsValidatorSource.replace(
+ /\s*\r?\n\s*/g,
+ ' ',
+);
+
const powerShellTlsValidatorBootstrap =
`if ($null -eq ("PulseInstallerCertificateValidator" -as [type])) { ` +
- `Add-Type -TypeDefinition ${powerShellSingleQuotedLiteral(powerShellTlsValidatorSource)} ` +
+ `Add-Type -TypeDefinition ${powerShellSingleQuotedLiteral(powerShellTlsValidatorInlineSource)} ` +
`}; `;
const powerShellLoadCustomCa = (pathExpression: string) =>