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.
This commit is contained in:
rcourtman 2025-10-19 15:17:59 +00:00
parent 97c895dbb1
commit f81d77bb98
2 changed files with 31 additions and 24 deletions

View file

@ -1108,6 +1108,8 @@ create_lxc_container() {
# Run proxy installer if downloaded # Run proxy installer if downloaded
if [[ -f "$proxy_script" ]]; then if [[ -f "$proxy_script" ]]; then
chmod +x "$proxy_script" 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 if bash "$proxy_script" --ctid "$CTID" 2>&1 | tee /tmp/proxy-install-${CTID}.log; then
print_info "Temperature proxy installed successfully" print_info "Temperature proxy installed successfully"
else else

View file

@ -191,34 +191,39 @@ else
esac esac
# If fallback URL is provided (e.g., from Pulse setup script), use it directly # 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}" FALLBACK_URL="${FALLBACK_BASE%/}?arch=${ARCH_LABEL}"
print_info "Downloading $BINARY_NAME from Pulse server..." print_info "Downloading $BINARY_NAME from Pulse server..."
if ! curl -fsSL "$FALLBACK_URL" -o "$BINARY_PATH.tmp"; then if curl -fsSL "$FALLBACK_URL" -o "$BINARY_PATH.tmp" 2>/dev/null; then
print_error "Failed to download proxy binary from $FALLBACK_URL" DOWNLOAD_SUCCESS=true
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"
fi fi
fi
DOWNLOAD_URL="https://github.com/$GITHUB_REPO/releases/download/$VERSION/$BINARY_NAME" # Exit if both methods failed
print_info "Downloading $BINARY_NAME from GitHub..." if [[ "$DOWNLOAD_SUCCESS" != true ]]; then
if ! curl -fsSL "$DOWNLOAD_URL" -o "$BINARY_PATH.tmp"; then print_error "Failed to download binary from GitHub or Pulse server"
print_error "Failed to download binary from $DOWNLOAD_URL" exit 1
exit 1
fi
fi fi
# Make executable and move to final location # Make executable and move to final location