From 8194ce9e7a4c0194f12c05ec865733e4d3744703 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Mon, 20 Oct 2025 22:14:03 +0000 Subject: [PATCH] feat: add containerization detection to version endpoint Added containerized and containerId fields to /api/version endpoint to enable automatic temperature proxy installation for LXC containers. Changes: - Added Containerized bool field to VersionResponse - Added ContainerId string field to VersionResponse - Detect containerization by checking /run/systemd/container file - Extract container ID from hostname for LXC containers - Set deployment type from container type (lxc/docker) This allows the PVE setup script to: 1. Detect that Pulse is running in a container 2. Find the container ID by matching IPs 3. Automatically install pulse-sensor-proxy on the host 4. Configure bind mount for secure socket communication Fixes the issue where setup script showed 'Proxy not available' even when Pulse was containerized. --- internal/api/router.go | 16 ++++++++++++++++ internal/api/types.go | 2 ++ 2 files changed, 18 insertions(+) diff --git a/internal/api/router.go b/internal/api/router.go index 989cce6..ac29b05 100644 --- a/internal/api/router.go +++ b/internal/api/router.go @@ -2264,6 +2264,22 @@ func (r *Router) handleVersion(w http.ResponseWriter, req *http.Request) { DeploymentType: versionInfo.DeploymentType, } + // Detect containerization (LXC/Docker) + if containerType, err := os.ReadFile("/run/systemd/container"); err == nil { + response.Containerized = true + + // Try to get container ID from hostname (LXC containers often use CTID as hostname) + if hostname, err := os.Hostname(); err == nil { + // For LXC, try to extract numeric ID from hostname or use full hostname + response.ContainerId = hostname + } + + // Add container type to deployment type if not already set + if response.DeploymentType == "" { + response.DeploymentType = string(containerType) + } + } + // Add cached update info if available if cachedUpdate := r.updateManager.GetCachedUpdateInfo(); cachedUpdate != nil { response.UpdateAvailable = cachedUpdate.Available diff --git a/internal/api/types.go b/internal/api/types.go index bc191d2..622ec89 100644 --- a/internal/api/types.go +++ b/internal/api/types.go @@ -33,6 +33,8 @@ type VersionResponse struct { DeploymentType string `json:"deploymentType,omitempty"` UpdateAvailable bool `json:"updateAvailable"` LatestVersion string `json:"latestVersion,omitempty"` + Containerized bool `json:"containerized"` + ContainerId string `json:"containerId,omitempty"` } // ErrorResponse represents an error response