feat: Add --local-binary flag to install-temp-proxy.sh for pre-release testing

Allows testing the proxy installation with a locally-built binary instead
of requiring a GitHub release. This enables proper E2E testing before
shipping a release.

Usage:
  ./install-temp-proxy.sh --ctid 112 --local-binary /path/to/pulse-temp-proxy

The script will:
- Use the provided binary instead of downloading from GitHub
- Still handle all setup (systemd service, SSH keys, bind mounts)
- Allow full integration testing without a release

This solves the chicken-and-egg problem of needing a release to test
the installation process.

Related to #528
This commit is contained in:
rcourtman 2025-10-12 22:25:49 +00:00
parent dd468a9e26
commit 58971aa982

View file

@ -32,6 +32,7 @@ fi
# Parse arguments # Parse arguments
CTID="" CTID=""
VERSION="latest" VERSION="latest"
LOCAL_BINARY=""
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case $1 in case $1 in
@ -43,6 +44,10 @@ while [[ $# -gt 0 ]]; do
VERSION="$2" VERSION="$2"
shift 2 shift 2
;; ;;
--local-binary)
LOCAL_BINARY="$2"
shift 2
;;
*) *)
print_error "Unknown option: $1" print_error "Unknown option: $1"
exit 1 exit 1
@ -52,7 +57,7 @@ done
if [[ -z "$CTID" ]]; then if [[ -z "$CTID" ]]; then
print_error "Missing required argument: --ctid <container-id>" print_error "Missing required argument: --ctid <container-id>"
echo "Usage: $0 --ctid <container-id> [--version <version>]" echo "Usage: $0 --ctid <container-id> [--version <version>] [--local-binary <path>]"
exit 1 exit 1
fi fi
@ -64,9 +69,26 @@ fi
print_info "Installing pulse-temp-proxy for container $CTID" print_info "Installing pulse-temp-proxy for container $CTID"
# Determine download URL BINARY_PATH="/usr/local/bin/pulse-temp-proxy"
GITHUB_REPO="rcourtman/Pulse" SERVICE_PATH="/etc/systemd/system/pulse-temp-proxy.service"
if [[ "$VERSION" == "latest" ]]; then SOCKET_PATH="/var/run/pulse-temp-proxy.sock"
SSH_DIR="/var/lib/pulse-temp-proxy/ssh"
# Install binary - either from local file or download from GitHub
if [[ -n "$LOCAL_BINARY" ]]; then
# Use local binary for testing
print_info "Using local binary: $LOCAL_BINARY"
if [[ ! -f "$LOCAL_BINARY" ]]; then
print_error "Local binary not found: $LOCAL_BINARY"
exit 1
fi
cp "$LOCAL_BINARY" "$BINARY_PATH"
chmod +x "$BINARY_PATH"
print_info "Binary installed to $BINARY_PATH"
else
# Download from GitHub release
GITHUB_REPO="rcourtman/Pulse"
if [[ "$VERSION" == "latest" ]]; then
RELEASE_URL="https://api.github.com/repos/$GITHUB_REPO/releases/latest" RELEASE_URL="https://api.github.com/repos/$GITHUB_REPO/releases/latest"
print_info "Fetching latest release info..." print_info "Fetching latest release info..."
RELEASE_DATA=$(curl -fsSL "$RELEASE_URL") RELEASE_DATA=$(curl -fsSL "$RELEASE_URL")
@ -76,11 +98,11 @@ if [[ "$VERSION" == "latest" ]]; then
exit 1 exit 1
fi fi
print_info "Latest version: $VERSION" print_info "Latest version: $VERSION"
fi fi
# Detect architecture # Detect architecture
ARCH=$(uname -m) ARCH=$(uname -m)
case $ARCH in case $ARCH in
x86_64) x86_64)
BINARY_NAME="pulse-temp-proxy-linux-amd64" BINARY_NAME="pulse-temp-proxy-linux-amd64"
;; ;;
@ -94,25 +116,22 @@ case $ARCH in
print_error "Unsupported architecture: $ARCH" print_error "Unsupported architecture: $ARCH"
exit 1 exit 1
;; ;;
esac esac
DOWNLOAD_URL="https://github.com/$GITHUB_REPO/releases/download/$VERSION/$BINARY_NAME" DOWNLOAD_URL="https://github.com/$GITHUB_REPO/releases/download/$VERSION/$BINARY_NAME"
BINARY_PATH="/usr/local/bin/pulse-temp-proxy"
SERVICE_PATH="/etc/systemd/system/pulse-temp-proxy.service"
SOCKET_PATH="/var/run/pulse-temp-proxy.sock"
SSH_DIR="/var/lib/pulse-temp-proxy/ssh"
# Download binary # Download binary
print_info "Downloading $BINARY_NAME..." print_info "Downloading $BINARY_NAME..."
if ! curl -fsSL "$DOWNLOAD_URL" -o "$BINARY_PATH.tmp"; then if ! curl -fsSL "$DOWNLOAD_URL" -o "$BINARY_PATH.tmp"; then
print_error "Failed to download binary from $DOWNLOAD_URL" print_error "Failed to download binary from $DOWNLOAD_URL"
exit 1 exit 1
fi fi
# Make executable and move to final location # Make executable and move to final location
chmod +x "$BINARY_PATH.tmp" chmod +x "$BINARY_PATH.tmp"
mv "$BINARY_PATH.tmp" "$BINARY_PATH" mv "$BINARY_PATH.tmp" "$BINARY_PATH"
print_info "Binary installed to $BINARY_PATH" print_info "Binary installed to $BINARY_PATH"
fi
# Create SSH key directory # Create SSH key directory
mkdir -p "$SSH_DIR" mkdir -p "$SSH_DIR"