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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
feat: harden temperature proxy installation with better validation and error handling
rcourtmand421f101bae4
diff --git a/internal/api/config_handlers.go b/internal/api/config_handlers.goindex ebae077c1f..0d48535ada 100644--- a/internal/api/config_handlers.go+++ b/internal/api/config_handlers.go@@ -3734,79 +3734,7 @@ if [ "$TEMP_MONITORING_AVAILABLE" = true ] && [ "$PULSE_IS_CONTAINERIZED" = trueTEMP_MONITORING_AVAILABLE=falsefi- if [ "$TEMP_MONITORING_AVAILABLE" = true ]; then- # Configure socket bind mount and restart container automatically- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"- echo "Finalizing Setup"- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"- echo ""- echo "Configuring socket bind mount for container $PULSE_CTID..."-- # Configure bind mount for proxy socket- pct set "$PULSE_CTID" -mp0 /run/pulse-sensor-proxy,mp=/mnt/pulse-proxy-- CONTAINER_RESTARTED=false- # Check if container is currently running- if pct status "$PULSE_CTID" 2>/dev/null | grep -q "running"; then- echo ""- echo "⚠️ Container $PULSE_CTID must be restarted to expose the proxy socket."- echo "Restart now? [Y/n]"- printf "> "- if [ -t 0 ]; then- read -n 1 -r RESTART_REPLY- echo ""- else- if read -n 1 -r RESTART_REPLY </dev/tty 2>/dev/null; then- echo ""- else- RESTART_REPLY="n"- echo "(No terminal available - skipping automatic restart)"- fi- fi- RESTART_REPLY=${RESTART_REPLY:-Y}- if [[ "$RESTART_REPLY" =~ ^[Yy]$ ]]; then- echo ""- echo "Restarting container $PULSE_CTID..."- if pct stop "$PULSE_CTID" && sleep 2 && pct start "$PULSE_CTID"; then- echo " ✓ Container restarted"- CONTAINER_RESTARTED=true- else- echo " ✗ Failed to restart container automatically."- echo " Please run: pct stop $PULSE_CTID && sleep 2 && pct start $PULSE_CTID"- fi- else- echo ""- echo "Please restart manually when ready:"- echo " pct stop $PULSE_CTID && sleep 2 && pct start $PULSE_CTID"- fi- else- echo "Container is stopped, starting it now..."-- # Set up trap to restart container even if script is interrupted- trap "echo 'Starting container before exit...'; pct start $PULSE_CTID 2>/dev/null || true" EXIT INT TERM-- if pct start "$PULSE_CTID"; then- CONTAINER_RESTARTED=true- echo " ✓ Container started successfully"- echo ""- else- echo " ✗ Failed to start container $PULSE_CTID automatically."- fi-- # Clear the trap after successful start- trap - EXIT INT TERM- fi-- if [ "$CONTAINER_RESTARTED" = true ]; then- if ! pct exec "$PULSE_CTID" -- test -S /mnt/pulse-proxy/pulse-sensor-proxy.sock 2>/dev/null; then- echo " ✗ Proxy socket not visible inside the container (/mnt/pulse-proxy/pulse-sensor-proxy.sock)"- echo " Verify the bind mount and container restart completed successfully."- TEMP_MONITORING_AVAILABLE=false- fi- else- TEMP_MONITORING_AVAILABLE=false- fi- fi+ # Note: Mount configuration and container restart are handled by the installerelseecho ""echo "⚠️ Proxy installation had issues - you may need to configure manually"diff --git a/scripts/install-sensor-proxy.sh b/scripts/install-sensor-proxy.shindex 9dc23a015a..8a77ffc42b 100755--- a/scripts/install-sensor-proxy.sh+++ b/scripts/install-sensor-proxy.sh@@ -198,15 +198,28 @@ elseif [[ "$VERSION" == "latest" ]]; thenRELEASE_URL="https://api.github.com/repos/$GITHUB_REPO/releases/latest"print_info "Fetching latest release info..."- RELEASE_DATA=$(curl -fsSL "$RELEASE_URL" 2>/dev/null)+ RELEASE_ERROR=$(mktemp)+ RELEASE_DATA=$(curl -fsSL "$RELEASE_URL" 2>"$RELEASE_ERROR")+ CURL_EXIT=$?+ if [ $CURL_EXIT -ne 0 ] && [ -s "$RELEASE_ERROR" ]; then+ print_warn "Failed to fetch GitHub release info: $(cat "$RELEASE_ERROR")"+ fi+ rm -f "$RELEASE_ERROR"VERSION=$(echo "$RELEASE_DATA" | grep -o '"tag_name": "[^"]*"' | cut -d'"' -f4)if [[ -n "$VERSION" ]]; thenprint_info "Latest version: $VERSION"DOWNLOAD_URL="https://github.com/$GITHUB_REPO/releases/download/$VERSION/$BINARY_NAME"print_info "Downloading $BINARY_NAME from GitHub..."- if curl -fsSL "$DOWNLOAD_URL" -o "$BINARY_PATH.tmp" 2>/dev/null; then+ DOWNLOAD_ERROR=$(mktemp)+ if curl -fsSL "$DOWNLOAD_URL" -o "$BINARY_PATH.tmp" 2>"$DOWNLOAD_ERROR"; thenDOWNLOAD_SUCCESS=true+ rm -f "$DOWNLOAD_ERROR"+ else+ if [ -s "$DOWNLOAD_ERROR" ]; then+ print_warn "GitHub download failed: $(cat "$DOWNLOAD_ERROR")"+ fi+ rm -f "$DOWNLOAD_ERROR"fififi@@ -215,14 +228,22 @@ elseif [[ "$DOWNLOAD_SUCCESS" != true ]] && [[ -n "$FALLBACK_BASE" ]]; thenFALLBACK_URL="${FALLBACK_BASE%/}?arch=${ARCH_LABEL}"print_info "Downloading $BINARY_NAME from Pulse server..."- if curl -fsSL "$FALLBACK_URL" -o "$BINARY_PATH.tmp" 2>/dev/null; then+ FALLBACK_ERROR=$(mktemp)+ if curl -fsSL "$FALLBACK_URL" -o "$BINARY_PATH.tmp" 2>"$FALLBACK_ERROR"; thenDOWNLOAD_SUCCESS=true+ rm -f "$FALLBACK_ERROR"+ else+ if [ -s "$FALLBACK_ERROR" ]; then+ print_error "Pulse server download failed: $(cat "$FALLBACK_ERROR")"+ fi+ rm -f "$FALLBACK_ERROR"fifi# Exit if both methods failedif [[ "$DOWNLOAD_SUCCESS" != true ]]; then- print_error "Failed to download binary from GitHub or Pulse server"+ print_error "Failed to download binary from GitHub and Pulse server"+ print_error "Check network connectivity and firewall rules"exit 1fi@@ -388,9 +409,24 @@ fi# Reload systemd and start serviceprint_info "Enabling and starting service..."-systemctl daemon-reload-systemctl enable pulse-sensor-proxy.service-systemctl restart pulse-sensor-proxy.service+if ! systemctl daemon-reload; then+ print_error "Failed to reload systemd daemon"+ journalctl -u pulse-sensor-proxy -n 20 --no-pager+ exit 1+fi++if ! systemctl enable pulse-sensor-proxy.service; then+ print_error "Failed to enable pulse-sensor-proxy service"+ journalctl -u pulse-sensor-proxy -n 20 --no-pager+ exit 1+fi++if ! systemctl restart pulse-sensor-proxy.service; then+ print_error "Failed to start pulse-sensor-proxy service"+ print_error "Check service logs:"+ journalctl -u pulse-sensor-proxy -n 20 --no-pager+ exit 1+fi# Wait for socket to appearprint_info "Waiting for socket..."@@ -783,17 +819,25 @@ if [[ -z "$CURRENT_MP" ]]; thenexit 1fiprint_info "Configuring container mount using $CURRENT_MP..."- if pct set "$CTID" -${CURRENT_MP} "/run/pulse-sensor-proxy,mp=${MOUNT_TARGET},replicate=0" 2>/dev/null; then+ SET_ERROR=$(pct set "$CTID" -${CURRENT_MP} "/run/pulse-sensor-proxy,mp=${MOUNT_TARGET},replicate=0" 2>&1)+ if [ $? -eq 0 ]; thenMOUNT_UPDATED=trueelseHOTPLUG_FAILED=true+ if [ -n "$SET_ERROR" ]; then+ print_warn "pct set failed: $SET_ERROR"+ fifielseprint_info "Container already has socket mount configured ($CURRENT_MP)"- if pct set "$CTID" -${CURRENT_MP} "/run/pulse-sensor-proxy,mp=${MOUNT_TARGET},replicate=0" 2>/dev/null; then+ SET_ERROR=$(pct set "$CTID" -${CURRENT_MP} "/run/pulse-sensor-proxy,mp=${MOUNT_TARGET},replicate=0" 2>&1)+ if [ $? -eq 0 ]; thenMOUNT_UPDATED=trueelseHOTPLUG_FAILED=true+ if [ -n "$SET_ERROR" ]; then+ print_warn "pct set failed: $SET_ERROR"+ fififi@@ -808,6 +852,14 @@ if [[ "$HOTPLUG_FAILED" = true ]]; thenMOUNT_UPDATED=truefi+# Verify mount configuration actually persisted+if ! pct config "$CTID" | grep -q "^${CURRENT_MP}:"; then+ print_error "Failed to persist mount configuration for $CURRENT_MP"+ print_error "Expected mount not found in container config"+ exit 1+fi+print_info "✓ Mount configuration verified in container config"+# Remove legacy lxc.mount.entry directives if presentif grep -q "lxc.mount.entry: /run/pulse-sensor-proxy" "$LXC_CONFIG"; thenprint_info "Removing legacy lxc.mount.entry directives for pulse-sensor-proxy"@@ -829,13 +881,18 @@ fi# Verify socket directory and file inside containerif [[ "$HOTPLUG_FAILED" = true && "$CT_RUNNING" = true ]]; thenprint_warn "Skipping socket verification until container $CTID is restarted."+ print_warn "Please restart container and verify socket manually:"+ print_warn " pct stop $CTID && sleep 2 && pct start $CTID"+ print_warn " pct exec $CTID -- test -S ${MOUNT_TARGET}/pulse-sensor-proxy.sock && echo 'Socket OK'"elseprint_info "Verifying secure communication channel..."if pct exec "$CTID" -- test -S "${MOUNT_TARGET}/pulse-sensor-proxy.sock"; thenprint_info "✓ Secure socket communication ready"else- print_warn "Socket not visible at ${MOUNT_TARGET}/pulse-sensor-proxy.sock"- print_info "Check container configuration and restart if necessary"+ print_error "Socket not visible at ${MOUNT_TARGET}/pulse-sensor-proxy.sock"+ print_error "Mount configuration verified but socket not accessible in container"+ print_error "This indicates a mount or restart issue"+ exit 1fifi