Normalize line endings in install scripts and enhance service stop commands for robustness

This commit is contained in:
Jeppe Bundgaard
2026-06-30 11:06:33 +02:00
parent 7ccbb68ffa
commit bd87e94472
4 changed files with 47 additions and 16 deletions
@@ -2,6 +2,7 @@
it('builds the installer around the compose stack artifacts and management polling config', function (): void {
$managerSource = file_get_contents(app_path('classes/edge_gateway_manager.php'));
$installServiceSource = file_get_contents(app_path('classes/edge_gateway_install_service.php'));
$serviceSource = file_get_contents(app_path('resources/edge-gateway-agent/truckwash-edge-agent.service'));
$stackServiceSource = file_get_contents(app_path('resources/edge-gateway-agent/truckwash-edge-gateway-stack.service'));
$launcherSource = file_get_contents(app_path('resources/edge-gateway-agent/gateway-launcher.sh'));
@@ -42,11 +43,14 @@ it('builds the installer around the compose stack artifacts and management polli
expect($managerSource)->toContain('cleanup_existing_installation()');
expect($managerSource)->toContain('systemctl stop truckwash-edge-gateway-stack.service');
expect($managerSource)->toContain('systemctl stop truckwash-edge-agent.service');
expect($managerSource)->toContain('TRUCKWASH_INSTALL_DIR="$INSTALL_DIR" "$INSTALL_DIR/gateway-launcher.sh" down');
expect($managerSource)->toContain('TRUCKWASH_INSTALL_DIR="$INSTALL_DIR" "$INSTALL_DIR/gateway-launcher.sh" down >/dev/null 2>&1 || true');
expect($managerSource)->toContain('docker rm -f');
expect($managerSource)->toContain('truckwash-minio');
expect($managerSource)->toContain('truckwash-minio >/dev/null 2>&1 || true');
expect($managerSource)->toContain('rm -f "$STACK_SERVICE_PATH" "$LEGACY_SERVICE_PATH"');
expect($managerSource)->toContain('rm -rf "$INSTALL_DIR"');
expect($managerSource)->toContain('systemctl reset-failed truckwash-edge-agent.service >/dev/null 2>&1 || true');
expect($managerSource)->toContain('return 0');
expect($managerSource)->toContain('report_install_status() {');
expect($managerSource)->toContain('begin_install_phase "START_STACK" "Starting edge gateway stack"');
expect($managerSource)->toContain('report_install_status "RUNNING" "$CURRENT_STEP_CODE" "$CURRENT_STEP"');
@@ -67,6 +71,8 @@ it('builds the installer around the compose stack artifacts and management polli
expect($managerSource)->toContain('journalctl -u truckwash-edge-gateway-stack.service -n 60 --no-pager || true');
expect($managerSource)->not->toContain('agent.mjs');
expect($managerSource)->toContain("'brokerUrl' => \$this->buildBrokerPublicUrl()");
expect($installServiceSource)->toContain('normalizeLineEndings($this->manager()->buildInstallScript($plainToken))');
expect($installServiceSource)->toContain('str_replace(["\r\n", "\r"], "\n", $contents)');
expect($serviceSource)->toContain('Description=TruckWash Edge Agent Compatibility Unit');
expect($serviceSource)->toContain('ExecStart=/opt/truckwash-edge-agent/gateway-launcher.sh up');
expect($serviceSource)->toContain('ExecReload=/opt/truckwash-edge-agent/gateway-launcher.sh reconcile');