From d07ad8fd3e62cdef8ec88a753c3c94691002682b Mon Sep 17 00:00:00 2001 From: rcourtman Date: Wed, 26 Nov 2025 10:05:43 +0000 Subject: [PATCH] fix: use correct script paths in unified agent handlers The unified agent handlers were using r.config.AppRoot which pointed to /app, but scripts are in /opt/pulse/scripts. Updated to match the pattern used by other script handlers - check /opt/pulse/scripts first, then fall back to project root for dev environment. Also added no-cache headers to prevent stale scripts being served. --- internal/api/unified_agent.go | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/internal/api/unified_agent.go b/internal/api/unified_agent.go index f80ccff..e608aa6 100644 --- a/internal/api/unified_agent.go +++ b/internal/api/unified_agent.go @@ -19,13 +19,20 @@ func (r *Router) handleDownloadUnifiedInstallScript(w http.ResponseWriter, req * return } - scriptPath := filepath.Join(r.config.AppRoot, "scripts", "install.sh") + // Prevent caching - always serve the latest version + w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") + w.Header().Set("Pragma", "no-cache") + w.Header().Set("Expires", "0") - // Check if file exists + scriptPath := "/opt/pulse/scripts/install.sh" if _, err := os.Stat(scriptPath); os.IsNotExist(err) { - log.Error().Str("path", scriptPath).Msg("Unified install script not found") - http.Error(w, "Install script not found", http.StatusNotFound) - return + // Fallback to project root (dev environment) + scriptPath = filepath.Join(r.projectRoot, "scripts", "install.sh") + if _, err := os.Stat(scriptPath); os.IsNotExist(err) { + log.Error().Str("path", scriptPath).Msg("Unified install script not found") + http.Error(w, "Install script not found", http.StatusNotFound) + return + } } w.Header().Set("Content-Type", "text/x-shellscript") @@ -40,13 +47,20 @@ func (r *Router) handleDownloadUnifiedInstallScriptPS(w http.ResponseWriter, req return } - scriptPath := filepath.Join(r.config.AppRoot, "scripts", "install.ps1") + // Prevent caching - always serve the latest version + w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") + w.Header().Set("Pragma", "no-cache") + w.Header().Set("Expires", "0") - // Check if file exists + scriptPath := "/opt/pulse/scripts/install.ps1" if _, err := os.Stat(scriptPath); os.IsNotExist(err) { - log.Error().Str("path", scriptPath).Msg("Unified PowerShell install script not found") - http.Error(w, "Install script not found", http.StatusNotFound) - return + // Fallback to project root (dev environment) + scriptPath = filepath.Join(r.projectRoot, "scripts", "install.ps1") + if _, err := os.Stat(scriptPath); os.IsNotExist(err) { + log.Error().Str("path", scriptPath).Msg("Unified PowerShell install script not found") + http.Error(w, "Install script not found", http.StatusNotFound) + return + } } w.Header().Set("Content-Type", "text/plain")