From f81d77bb988740e6b3726e8a493857387bf55a5b Mon Sep 17 00:00:00 2001 From: rcourtman Date: Sun, 19 Oct 2025 15:17:59 +0000 Subject: [PATCH] fix: fall back to Pulse server when GitHub download fails for pulse-sensor-proxy The install-sensor-proxy.sh script now tries GitHub releases first, then falls back to downloading from the Pulse server if GitHub fails or doesn't have the binary (common when building from main). The LXC installer sets PULSE_SENSOR_PROXY_FALLBACK_URL to point to the Pulse server running inside the newly created LXC, ensuring the proxy binary can be downloaded from /api/install/pulse-sensor-proxy. This fixes the issue where installing with --main would fail to install pulse-sensor-proxy on the host because GitHub releases don't include it yet. --- install.sh | 2 ++ scripts/install-sensor-proxy.sh | 53 ++++++++++++++++++--------------- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/install.sh b/install.sh index d90821c..95f9826 100755 --- a/install.sh +++ b/install.sh @@ -1108,6 +1108,8 @@ create_lxc_container() { # Run proxy installer if downloaded if [[ -f "$proxy_script" ]]; then chmod +x "$proxy_script" + # Set fallback URL to download from Pulse server inside the LXC + export PULSE_SENSOR_PROXY_FALLBACK_URL="http://${IP}:${frontend_port}/api/install/pulse-sensor-proxy" if bash "$proxy_script" --ctid "$CTID" 2>&1 | tee /tmp/proxy-install-${CTID}.log; then print_info "Temperature proxy installed successfully" else diff --git a/scripts/install-sensor-proxy.sh b/scripts/install-sensor-proxy.sh index 0456a35..a59e814 100755 --- a/scripts/install-sensor-proxy.sh +++ b/scripts/install-sensor-proxy.sh @@ -191,34 +191,39 @@ else esac # If fallback URL is provided (e.g., from Pulse setup script), use it directly - if [[ -n "$FALLBACK_BASE" ]]; then + # Try GitHub first for releases + GITHUB_REPO="rcourtman/Pulse" + DOWNLOAD_SUCCESS=false + + if [[ "$VERSION" == "latest" ]]; then + RELEASE_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) + VERSION=$(echo "$RELEASE_DATA" | grep -o '"tag_name": "[^"]*"' | cut -d'"' -f4) + + if [[ -n "$VERSION" ]]; then + print_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_SUCCESS=true + fi + fi + fi + + # Fall back to Pulse server if GitHub failed or fallback is provided + if [[ "$DOWNLOAD_SUCCESS" != true ]] && [[ -n "$FALLBACK_BASE" ]]; then FALLBACK_URL="${FALLBACK_BASE%/}?arch=${ARCH_LABEL}" print_info "Downloading $BINARY_NAME from Pulse server..." - if ! curl -fsSL "$FALLBACK_URL" -o "$BINARY_PATH.tmp"; then - print_error "Failed to download proxy binary from $FALLBACK_URL" - exit 1 - fi - else - # Fallback not provided, download from GitHub release - GITHUB_REPO="rcourtman/Pulse" - if [[ "$VERSION" == "latest" ]]; then - RELEASE_URL="https://api.github.com/repos/$GITHUB_REPO/releases/latest" - print_info "Fetching latest release info..." - RELEASE_DATA=$(curl -fsSL "$RELEASE_URL") - VERSION=$(echo "$RELEASE_DATA" | grep -o '"tag_name": "[^"]*"' | cut -d'"' -f4) - if [[ -z "$VERSION" ]]; then - print_error "Failed to determine latest version" - exit 1 - fi - print_info "Latest version: $VERSION" + if curl -fsSL "$FALLBACK_URL" -o "$BINARY_PATH.tmp" 2>/dev/null; then + DOWNLOAD_SUCCESS=true fi + fi - 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"; then - print_error "Failed to download binary from $DOWNLOAD_URL" - exit 1 - fi + # Exit if both methods failed + if [[ "$DOWNLOAD_SUCCESS" != true ]]; then + print_error "Failed to download binary from GitHub or Pulse server" + exit 1 fi # Make executable and move to final location