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
fix(installer): support local release archives on v6
rcourtmand7d757bddda8
diff --git a/install.sh b/install.shindex 3f514969a6..ac967569f0 100755--- a/install.sh+++ b/install.sh@@ -25,6 +25,7 @@ IN_DOCKER=falseENABLE_AUTO_UPDATES=falseFORCE_VERSION=""FORCE_CHANNEL=""+ARCHIVE_OVERRIDE="${PULSE_ARCHIVE_PATH:-}"SOURCE_BRANCH="main"CURRENT_INSTALL_CTID=""CONTAINER_CREATED_FOR_CLEANUP=false@@ -140,6 +141,7 @@ selected_update_channel() {build_container_install_command() {local install_cmd="bash /tmp/install.sh --in-container"+ local quoted_archive=""if [[ -n "${FORCE_VERSION:-}" ]]; theninstall_cmd="$install_cmd --version '$FORCE_VERSION'"@@ -147,6 +149,10 @@ build_container_install_command() {install_cmd="$install_cmd --rc"fi+ if [[ -n "${container_archive_dest:-}" ]]; then+ printf -v quoted_archive '%q' "$container_archive_dest"+ install_cmd="$install_cmd --archive $quoted_archive"+ fiif [[ -n "${auto_updates_flag:-}" ]]; theninstall_cmd="$install_cmd $auto_updates_flag"fi@@ -1386,6 +1392,10 @@ create_lxc_container() {exit 1fifi++ if [[ -n "$ARCHIVE_OVERRIDE" ]]; then+ ARCHIVE_OVERRIDE=$(resolve_archive_override "$ARCHIVE_OVERRIDE") || exit 1+ fiprint_info "Creating container..."@@ -1502,6 +1512,24 @@ create_lxc_container() {print_error "Failed to install dependencies in container"cleanup_on_errorfi++ local container_archive_source=""+ local container_archive_dest=""+ local container_archive_temp=false+ local archive_requested=false++ if [[ -n "$ARCHIVE_OVERRIDE" ]]; then+ archive_requested=true+ container_archive_source="$ARCHIVE_OVERRIDE"+ container_archive_dest="/tmp/$(basename "$container_archive_source")"+ elif [[ "$BUILD_FROM_SOURCE" != "true" ]]; then+ if prefetch_pulse_archive_for_container container_archive_source; then+ container_archive_temp=true+ container_archive_dest="/tmp/$(basename "$container_archive_source")"+ else+ print_warn "Host-side Pulse archive prefetch failed; falling back to in-container download."+ fi+ fi# Install Pulse inside containerprint_info "Installing Pulse..."@@ -1570,6 +1598,27 @@ create_lxc_container() {if [[ "$script_source" == "/tmp/pulse_install_"* ]]; thenrm -f "$script_source"fi++ if [[ -n "$container_archive_source" ]]; then+ print_info "Copying Pulse release archive to container..."+ if ! pct push $CTID "$container_archive_source" "$container_archive_dest" >/dev/null 2>&1; then+ if [[ "$container_archive_temp" == "true" ]]; then+ rm -f "$container_archive_source"+ fi+ if [[ "$archive_requested" == "true" ]]; then+ print_error "Failed to copy Pulse release archive to container"+ cleanup_on_error+ fi+ print_warn "Could not copy prefetched archive into container; falling back to in-container download."+ container_archive_source=""+ container_archive_dest=""+ container_archive_temp=false+ fi+ fi++ if [[ "$container_archive_temp" == "true" ]]; then+ rm -f "$container_archive_source"+ fi# Run installation with visible progresslocal install_cmd=""@@ -2164,24 +2213,185 @@ backup_existing() {fi}-download_pulse() {- # Check if we should build from source - do this FIRST to avoid confusing version messages- if [[ "$BUILD_FROM_SOURCE" == "true" ]]; then- if ! build_from_source "$SOURCE_BRANCH"; then- print_error "Source build failed"- exit 1- fi+resolve_archive_override() {+ local archive_path="$1"++ if [[ -z "$archive_path" ]]; then+ print_error "Archive path is required"+ return 1+ fi+ if [[ ! -f "$archive_path" ]]; then+ print_error "Archive not found: $archive_path"+ return 1+ fi+ if [[ ! -r "$archive_path" ]]; then+ print_error "Archive is not readable: $archive_path"+ return 1+ fi++ if command -v realpath >/dev/null 2>&1; then+ realpath "$archive_path"+ else+ printf '%s\n' "$archive_path"+ fi+}++infer_release_from_archive_name() {+ local archive_name+ archive_name=$(basename "$1")++ if [[ "$archive_name" =~ ^pulse-(v[0-9]+\.[0-9]+\.[0-9]+([-.][0-9A-Za-z.]+)*)-linux-(amd64|arm64|armv7)\.tar\.gz$ ]]; then+ printf '%s\n' "${BASH_REMATCH[1]}"+ return 0+ fi++ return 1+}++detect_pulse_architecture() {+ local raw_arch="${1:-$(uname -m)}"++ case $raw_arch in+ x86_64|amd64)+ printf 'amd64\n'+ ;;+ aarch64|arm64)+ printf 'arm64\n'+ ;;+ armv7l|armv7)+ printf 'armv7\n'+ ;;+ *)+ return 1+ ;;+ esac+}++find_pulse_binary_in_dir() {+ local dir="$1"++ if [[ -f "$dir/bin/pulse" ]]; then+ printf '%s\n' "$dir/bin/pulse"return 0fi+ if [[ -f "$dir/pulse" ]]; then+ printf '%s\n' "$dir/pulse"+ return 0+ fi++ return 1+}++detect_pulse_binary_architecture() {+ local binary_path="$1"+ local file_info=""+ local machine=""+ local machine_id=""++ if [[ ! -f "$binary_path" ]]; then+ return 1+ fi++ if command -v readelf >/dev/null 2>&1; then+ machine=$(LC_ALL=C readelf -h "$binary_path" 2>/dev/null | awk -F: '/Machine:/ {gsub(/^[[:space:]]+/, "", $2); print $2; exit}')+ case "$machine" in+ "Advanced Micro Devices X86-64")+ printf 'amd64\n'+ return 0+ ;;+ "AArch64")+ printf 'arm64\n'+ return 0+ ;;+ "ARM")+ printf 'armv7\n'+ return 0+ ;;+ esac+ fi++ if command -v file >/dev/null 2>&1; then+ file_info=$(LC_ALL=C file -b "$binary_path" 2>/dev/null || true)+ case "$file_info" in+ *"x86-64"*)+ printf 'amd64\n'+ return 0+ ;;+ *"aarch64"*|*"ARM64"*)+ printf 'arm64\n'+ return 0+ ;;+ *" ARM "*|ARM,*|*" EABI5"*)+ printf 'armv7\n'+ return 0+ ;;+ esac+ fi++ machine_id=$(dd if="$binary_path" bs=1 skip=18 count=2 2>/dev/null | od -An -tu2 2>/dev/null | tr -d '[:space:]')+ case "$machine_id" in+ 62)+ printf 'amd64\n'+ return 0+ ;;+ 183)+ printf 'arm64\n'+ return 0+ ;;+ 40)+ printf 'armv7\n'+ return 0+ ;;+ esac++ return 1+}++validate_pulse_binary_architecture() {+ local binary_path="$1"+ local target_arch="$2"+ local archive_label="${3:-archive}"+ local binary_arch=""++ if [[ -z "$target_arch" ]]; then+ print_error "Target architecture is required for archive validation"+ return 1+ fi++ binary_arch=$(detect_pulse_binary_architecture "$binary_path" 2>/dev/null || true)+ if [[ -z "$binary_arch" ]]; then+ print_error "Could not determine Pulse binary architecture from $archive_label"+ print_info "Use an official Pulse Linux release tarball for this machine."+ return 1+ fi++ if [[ "$binary_arch" != "$target_arch" ]]; then+ print_error "Archive architecture mismatch: $archive_label contains $binary_arch but this target requires $target_arch"+ print_info "Download the official Pulse release tarball for the target architecture."+ return 1+ fi++ return 0+}++create_temp_archive_path() {+ local prefix="$1"+ local temp_base=""++ temp_base=$(mktemp "${prefix}-XXXXXX") || return 1+ rm -f "$temp_base"+ printf '%s.tar.gz\n' "$temp_base"+}- print_info "Downloading Pulse..."+resolve_target_release() {+ if [[ -n "${LATEST_RELEASE:-}" ]]; then+ return 0+ fi- # Check for forced version firstif [[ -n "${FORCE_VERSION}" ]]; thenLATEST_RELEASE="${FORCE_VERSION}"print_info "Installing specific version: $LATEST_RELEASE"- # Verify the version exists (with timeout)if command -v timeout >/dev/null 2>&1; thenif ! timeout 15 curl -fsS --connect-timeout 10 --max-time 30 "https://api.github.com/repos/$GITHUB_REPO/releases/tags/$LATEST_RELEASE" > /dev/null 2>&1; thenprint_warn "Could not verify version $LATEST_RELEASE, proceeding anyway..."@@ -2191,283 +2401,367 @@ download_pulse() {print_warn "Could not verify version $LATEST_RELEASE, proceeding anyway..."fifi- else- # UPDATE_CHANNEL should already be set by main(), but set default if not- if [[ -z "${UPDATE_CHANNEL:-}" ]]; then- UPDATE_CHANNEL="stable"-- # Allow override via command line- if [[ -n "${FORCE_CHANNEL}" ]]; then- UPDATE_CHANNEL="${FORCE_CHANNEL}"- print_info "Using $UPDATE_CHANNEL channel from command line"- elif [[ -f "$CONFIG_DIR/system.json" ]]; then- CONFIGURED_CHANNEL=$(cat "$CONFIG_DIR/system.json" 2>/dev/null | grep -o '"updateChannel"[[:space:]]*:[[:space:]]*"[^"]*"' | sed 's/.*"\([^"]*\)"$/\1/' || true)- if [[ "$CONFIGURED_CHANNEL" == "rc" ]]; then- UPDATE_CHANNEL="rc"- print_info "Prerelease channel detected in configuration"- fi+ return 0+ fi++ if [[ -z "${UPDATE_CHANNEL:-}" ]]; then+ UPDATE_CHANNEL="stable"++ if [[ -n "${FORCE_CHANNEL}" ]]; then+ UPDATE_CHANNEL="${FORCE_CHANNEL}"+ print_info "Using $UPDATE_CHANNEL channel from command line"+ elif [[ -f "$CONFIG_DIR/system.json" ]]; then+ CONFIGURED_CHANNEL=$(cat "$CONFIG_DIR/system.json" 2>/dev/null | grep -o '"updateChannel"[[:space:]]*:[[:space:]]*"[^"]*"' | sed 's/.*"\([^"]*\)"$/\1/' || true)+ if [[ "$CONFIGURED_CHANNEL" == "rc" ]]; then+ UPDATE_CHANNEL="rc"+ print_info "Prerelease channel detected in configuration"fifi+ fi- # Get appropriate release based on channel (with timeout)- # Both stable and prerelease channels now use /releases endpoint to handle draft releases- if command -v timeout >/dev/null 2>&1; then- RELEASES_JSON=$(timeout 15 curl -s --connect-timeout 10 --max-time 30 https://api.github.com/repos/$GITHUB_REPO/releases 2>/dev/null || true)- else- RELEASES_JSON=$(curl -s --connect-timeout 10 --max-time 30 https://api.github.com/repos/$GITHUB_REPO/releases 2>/dev/null || true)- fi+ local releases_json=""+ if command -v timeout >/dev/null 2>&1; then+ releases_json=$(timeout 15 curl -s --connect-timeout 10 --max-time 30 "https://api.github.com/repos/$GITHUB_REPO/releases" 2>/dev/null || true)+ else+ releases_json=$(curl -s --connect-timeout 10 --max-time 30 "https://api.github.com/repos/$GITHUB_REPO/releases" 2>/dev/null || true)+ fi- if [[ -n "$RELEASES_JSON" ]]; then- if [[ "$UPDATE_CHANNEL" == "rc" ]]; then- # Prerelease channel: get latest release (including prereleases, but skip drafts)- if command -v jq >/dev/null 2>&1; then- LATEST_RELEASE=$(echo "$RELEASES_JSON" | jq -r '[.[] | select(.draft == false)][0].tag_name' 2>/dev/null || true)- else- # Fallback without jq: grep for first non-draft tag_name- LATEST_RELEASE=$(echo "$RELEASES_JSON" | grep -v '"draft": true' | grep '"tag_name":' | head -1 | sed -E 's/.*"([^"]+)".*/\1/' || true)- fi+ if [[ -n "$releases_json" ]]; then+ if [[ "$UPDATE_CHANNEL" == "rc" ]]; then+ # Prerelease channel: get latest release (including prereleases, but skip drafts)+ if command -v jq >/dev/null 2>&1; then+ LATEST_RELEASE=$(echo "$releases_json" | jq -r '[.[] | select(.draft == false)][0].tag_name' 2>/dev/null || true)else- # Stable channel: Get latest non-draft, non-prerelease- if command -v jq >/dev/null 2>&1; then- LATEST_RELEASE=$(echo "$RELEASES_JSON" | jq -r '[.[] | select(.draft == false and .prerelease == false)][0].tag_name' 2>/dev/null || true)- else- # Fallback without jq: filter out both draft and prerelease- LATEST_RELEASE=$(echo "$RELEASES_JSON" | awk '/"draft": true/,/"tag_name":/ {next} /"prerelease": true/,/"tag_name":/ {next} /"tag_name":/ {print; exit}' | sed -E 's/.*"([^"]+)".*/\1/' || true)- fi+ LATEST_RELEASE=$(echo "$releases_json" | grep -v '"draft": true' | grep '"tag_name":' | head -1 | sed -E 's/.*"([^"]+)".*/\1/' || true)+ fi+ else+ if command -v jq >/dev/null 2>&1; then+ LATEST_RELEASE=$(echo "$releases_json" | jq -r '[.[] | select(.draft == false and .prerelease == false)][0].tag_name' 2>/dev/null || true)+ else+ LATEST_RELEASE=$(echo "$releases_json" | awk '/"draft": true/,/"tag_name":/ {next} /"prerelease": true/,/"tag_name":/ {next} /"tag_name":/ {print; exit}' | sed -E 's/.*"([^"]+)".*/\1/' || true)fifi+ fi- # Fallback: Try direct GitHub redirect if API fails- if [[ -z "$LATEST_RELEASE" ]]; then- print_info "GitHub API unavailable, trying alternative method..."- local redirect_version=""- redirect_version=$(get_latest_release_from_redirect 2>/dev/null || true)- if [[ -n "$redirect_version" ]]; then- LATEST_RELEASE="$redirect_version"+ if [[ -z "$LATEST_RELEASE" ]]; then+ print_info "GitHub API unavailable, trying alternative method..."+ local redirect_version=""+ redirect_version=$(get_latest_release_from_redirect 2>/dev/null || true)+ if [[ -n "$redirect_version" ]]; then+ LATEST_RELEASE="$redirect_version"+ fi+ fi++ if [[ -z "$LATEST_RELEASE" ]]; then+ print_warn "Could not determine latest release from GitHub, using fallback version"+ LATEST_RELEASE="v4.5.1"+ fi++ print_info "Latest version: $LATEST_RELEASE"+}++download_release_archive() {+ local release="$1"+ local pulse_arch="$2"+ local archive_path="$3"++ local archive_name="pulse-${release}-linux-${pulse_arch}.tar.gz"+ local download_url="https://github.com/$GITHUB_REPO/releases/download/$release/${archive_name}"+ local checksums_url="https://github.com/$GITHUB_REPO/releases/download/$release/checksums.txt"+ local checksum_url=""+ local checksum_file=""+ local expected_checksum=""+ local actual_checksum=""++ DOWNLOAD_URL="$download_url"+ print_info "Downloading from: $DOWNLOAD_URL"++ if ! command -v sha256sum >/dev/null 2>&1; then+ print_error "sha256sum is required but not installed"+ return 1+ fi++ if ! wget -q --timeout=60 --tries=2 -O "$archive_path" "$download_url"; then+ print_error "Failed to download Pulse release"+ print_info "This can happen due to network issues or GitHub rate limiting"+ print_info "You can try downloading manually from: $download_url"+ return 1+ fi++ checksum_file=$(mktemp /tmp/pulse-checksum-XXXXXX)+ if wget -q --timeout=60 --tries=2 -O "$checksum_file" "$checksums_url" 2>/dev/null; then+ expected_checksum=$(grep -w "${archive_name}" "$checksum_file" 2>/dev/null | awk '{print $1}')+ fi+ rm -f "$checksum_file"++ if [[ -z "$expected_checksum" ]]; then+ checksum_url="${download_url}.sha256"+ checksum_file=$(mktemp /tmp/pulse-checksum-XXXXXX)+ if wget -q --timeout=60 --tries=2 -O "$checksum_file" "$checksum_url" 2>/dev/null; then+ expected_checksum=$(awk '{print $1}' "$checksum_file")+ fi+ rm -f "$checksum_file"+ fi++ if [[ -z "$expected_checksum" ]]; then+ print_error "Failed to download checksum for Pulse release"+ print_info "Refusing to install without checksum verification"+ return 1+ fi++ actual_checksum=$(sha256sum "$archive_path" | awk '{print $1}')+ if [[ "$actual_checksum" != "$expected_checksum" ]]; then+ print_error "Checksum verification failed for downloaded Pulse release"+ print_error "Expected: $expected_checksum"+ print_error "Got: $actual_checksum"+ return 1+ fi++ return 0+}++install_pulse_archive() {+ local archive_path="$1"+ local expected_release="${2:-}"+ local temp_extract=""+ local temp_extract2=""+ local installed_version=""+ local pulse_binary_path=""+ local target_arch=""++ if [[ ! -f "$archive_path" ]]; then+ print_error "Archive not found: $archive_path"+ return 1+ fi++ if [[ -z "$expected_release" ]]; then+ expected_release=$(infer_release_from_archive_name "$archive_path" 2>/dev/null || true)+ fi++ temp_extract=$(mktemp -d /tmp/pulse-extract-XXXXXX)+ if ! tar -xzf "$archive_path" -C "$temp_extract"; then+ print_error "Failed to extract Pulse release archive"+ rm -rf "$temp_extract"+ return 1+ fi++ pulse_binary_path=$(find_pulse_binary_in_dir "$temp_extract" 2>/dev/null || true)+ if [[ -z "$pulse_binary_path" ]]; then+ print_error "Pulse binary not found in archive"+ rm -rf "$temp_extract"+ return 1+ fi++ target_arch=$(detect_pulse_architecture 2>/dev/null || true)+ if [[ -z "$target_arch" ]]; then+ print_error "Unsupported architecture for archive install: $(uname -m)"+ rm -rf "$temp_extract"+ return 1+ fi++ if ! validate_pulse_binary_architecture "$pulse_binary_path" "$target_arch" "$(basename "$archive_path")"; then+ rm -rf "$temp_extract"+ return 1+ fi++ mkdir -p "$INSTALL_DIR/bin"++ if [[ -f "$INSTALL_DIR/bin/pulse" ]]; then+ mv "$INSTALL_DIR/bin/pulse" "$INSTALL_DIR/bin/pulse.old" 2>/dev/null || true+ fi++ if ! cp "$pulse_binary_path" "$INSTALL_DIR/bin/pulse"; then+ print_error "Failed to copy new binary to $INSTALL_DIR/bin/pulse"+ [[ -f "$INSTALL_DIR/bin/pulse.old" ]] && mv "$INSTALL_DIR/bin/pulse.old" "$INSTALL_DIR/bin/pulse"+ rm -rf "$temp_extract"+ return 1+ fi++ if [[ ! -f "$INSTALL_DIR/bin/pulse" ]]; then+ print_error "Binary installation failed - file not found after copy"+ [[ -f "$INSTALL_DIR/bin/pulse.old" ]] && mv "$INSTALL_DIR/bin/pulse.old" "$INSTALL_DIR/bin/pulse"+ rm -rf "$temp_extract"+ return 1+ fi++ install_additional_agent_binaries "$expected_release" "$temp_extract"+ deploy_agent_scripts "$temp_extract"++ chmod +x "$INSTALL_DIR/bin/pulse"+ chown -R pulse:pulse "$INSTALL_DIR"++ rm -f "$INSTALL_DIR/bin/pulse.old"+ ln -sf "$INSTALL_DIR/bin/pulse" /usr/local/bin/pulse+ print_success "Pulse binary installed to $INSTALL_DIR/bin/pulse"+ print_success "Symlink created at /usr/local/bin/pulse"++ if [[ -f "$temp_extract/VERSION" ]]; then+ cp "$temp_extract/VERSION" "$INSTALL_DIR/VERSION"+ chown pulse:pulse "$INSTALL_DIR/VERSION"+ fi++ installed_version=$("$INSTALL_DIR/bin/pulse" --version 2>/dev/null | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9\.]+)?' | head -1 || echo "unknown")+ if [[ -n "$expected_release" && "$installed_version" != "$expected_release" ]]; then+ print_warn "Version verification issue: Expected $expected_release but binary reports $installed_version"+ print_info "This can happen if the binary wasn't properly replaced. Trying to fix..."++ rm -f "$INSTALL_DIR/bin/pulse"+ temp_extract2=$(mktemp -d /tmp/pulse-extract2-XXXXXX)+ if ! tar -xzf "$archive_path" -C "$temp_extract2"; then+ print_warn "Failed to re-extract archive for version verification retry"+ else+ pulse_binary_path=$(find_pulse_binary_in_dir "$temp_extract2" 2>/dev/null || true)+ if [[ -n "$pulse_binary_path" ]]; then+ cp -f "$pulse_binary_path" "$INSTALL_DIR/bin/pulse"fi++ install_additional_agent_binaries "$expected_release" "$temp_extract2"+ deploy_agent_scripts "$temp_extract2"++ chmod +x "$INSTALL_DIR/bin/pulse"+ chown -R pulse:pulse "$INSTALL_DIR"fi+ rm -rf "$temp_extract2"- # Final fallback: Use a known good version- if [[ -z "$LATEST_RELEASE" ]]; then- print_warn "Could not determine latest release from GitHub, using fallback version"- LATEST_RELEASE="v4.5.1" # Known stable version as fallback+ installed_version=$("$INSTALL_DIR/bin/pulse" --version 2>/dev/null | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9\.]+)?' | head -1 || echo "unknown")+ if [[ "$installed_version" == "$expected_release" ]]; then+ print_success "Version issue resolved - now running $installed_version"+ else+ print_warn "Version mismatch persists. You may need to restart the service or reboot."fi+ elif [[ -n "$expected_release" ]]; then+ print_success "Version verified: $installed_version"+ elif [[ "$installed_version" != "unknown" ]]; then+ print_success "Version installed: $installed_version"+ else+ print_warn "Installed Pulse version could not be verified"+ fi++ restore_selinux_contexts+ rm -rf "$temp_extract"+ return 0+}- print_info "Latest version: $LATEST_RELEASE"+download_pulse() {+ # Check if we should build from source - do this FIRST to avoid confusing version messages+ if [[ "$BUILD_FROM_SOURCE" == "true" ]]; then+ if ! build_from_source "$SOURCE_BRANCH"; then+ print_error "Source build failed"+ exit 1+ fi+ return 0fi-+if [[ "$BUILD_FROM_SOURCE" == "true" && "$SKIP_DOWNLOAD" != "true" ]]; thenprint_error "Source build requested but download path was reached (internal error)"exit 1fi-+# Only do download if not building from sourceif [[ "$SKIP_DOWNLOAD" != "true" ]]; then- rm -f "$BUILD_FROM_SOURCE_MARKER"- # Detect architecture- ARCH=$(uname -m)- case $ARCH in- x86_64)- PULSE_ARCH="amd64"- ;;- aarch64)- PULSE_ARCH="arm64"- ;;- armv7l)- PULSE_ARCH="armv7"- ;;- *)- print_error "Unsupported architecture: $ARCH"- exit 1- ;;- esac-- print_info "Detected architecture: $ARCH ($PULSE_ARCH)"-- # Download architecture-specific release- ARCHIVE_NAME="pulse-${LATEST_RELEASE}-linux-${PULSE_ARCH}.tar.gz"- DOWNLOAD_URL="https://github.com/$GITHUB_REPO/releases/download/$LATEST_RELEASE/${ARCHIVE_NAME}"- CHECKSUMS_URL="https://github.com/$GITHUB_REPO/releases/download/$LATEST_RELEASE/checksums.txt"- print_info "Downloading from: $DOWNLOAD_URL"-- # Detect and stop existing service BEFORE downloading (to free the binary)- EXISTING_SERVICE=$(detect_service_name)- if timeout 5 systemctl is-active --quiet $EXISTING_SERVICE 2>/dev/null; then- print_info "Stopping existing Pulse service ($EXISTING_SERVICE)..."- safe_systemctl stop $EXISTING_SERVICE || true- sleep 2 # Give the process time to fully stop and release the binary- fi-- cd /tmp+ local archive_path=""+ local expected_release=""+ local raw_arch=""+ local pulse_arch=""+ local archive_from_temp=false+ local inferred_release=""- if ! command -v sha256sum >/dev/null 2>&1; then- print_error "sha256sum is required but not installed"- exit 1- fi+ rm -f "$BUILD_FROM_SOURCE_MARKER"- # Download with timeout (60 seconds should be enough for ~5MB file)- ARCHIVE_PATH="/tmp/$ARCHIVE_NAME"- if ! wget -q --timeout=60 --tries=2 -O "$ARCHIVE_PATH" "$DOWNLOAD_URL"; then- print_error "Failed to download Pulse release"- print_info "This can happen due to network issues or GitHub rate limiting"- print_info "You can try downloading manually from: $DOWNLOAD_URL"+ raw_arch=$(uname -m)+ pulse_arch=$(detect_pulse_architecture "$raw_arch") || {+ print_error "Unsupported architecture: $raw_arch"exit 1- fi+ }+ print_info "Detected architecture: $raw_arch ($pulse_arch)"- # Download and verify checksum (try new format first, fall back to old)- EXPECTED_CHECKSUM=""+ if [[ -n "$ARCHIVE_OVERRIDE" ]]; then+ archive_path=$(resolve_archive_override "$ARCHIVE_OVERRIDE") || exit 1+ inferred_release=$(infer_release_from_archive_name "$archive_path" 2>/dev/null || true)- # Try checksums.txt first (v4.29.0+)- if wget -q --timeout=60 --tries=2 -O "/tmp/checksums.txt" "$CHECKSUMS_URL" 2>/dev/null; then- EXPECTED_CHECKSUM=$(grep -w "${ARCHIVE_NAME}" /tmp/checksums.txt 2>/dev/null | awk '{print $1}')- rm -f /tmp/checksums.txt- fi+ if [[ -n "$FORCE_VERSION" && -n "$inferred_release" && "$FORCE_VERSION" != "$inferred_release" ]]; then+ print_error "Archive version $inferred_release does not match requested version $FORCE_VERSION"+ exit 1+ fi- # Fall back to individual .sha256 file (v4.28.0 and earlier)- if [ -z "$EXPECTED_CHECKSUM" ]; then- CHECKSUM_URL="${DOWNLOAD_URL}.sha256"- if wget -q --timeout=60 --tries=2 -O "${ARCHIVE_PATH}.sha256" "$CHECKSUM_URL" 2>/dev/null; then- EXPECTED_CHECKSUM=$(awk '{print $1}' "${ARCHIVE_PATH}.sha256")- rm -f "${ARCHIVE_PATH}.sha256"+ if [[ -n "$FORCE_VERSION" ]]; then+ expected_release="$FORCE_VERSION"+ else+ expected_release="$inferred_release"fi- fi- # If we still don't have a checksum, fail- if [ -z "$EXPECTED_CHECKSUM" ]; then- print_error "Failed to download checksum for Pulse release"- print_info "Refusing to install without checksum verification"- exit 1- fi+ if [[ -n "$expected_release" ]]; then+ LATEST_RELEASE="$expected_release"+ print_info "Installing Pulse from local archive: $archive_path"+ print_info "Archive version: $LATEST_RELEASE"+ else+ print_info "Installing Pulse from local archive: $archive_path"+ fi+ else+ print_info "Downloading Pulse..."+ resolve_target_release- # Verify the downloaded archive- ACTUAL_CHECKSUM=$(sha256sum "${ARCHIVE_PATH}" | awk '{print $1}')- if [ "$ACTUAL_CHECKSUM" != "$EXPECTED_CHECKSUM" ]; then- print_error "Checksum verification failed for downloaded Pulse release"- print_error "Expected: $EXPECTED_CHECKSUM"- print_error "Got: $ACTUAL_CHECKSUM"- exit 1- fi-- # Extract to temporary directory first- TEMP_EXTRACT="/tmp/pulse-extract-$$"- mkdir -p "$TEMP_EXTRACT"- tar -xzf "$ARCHIVE_PATH" -C "$TEMP_EXTRACT"-- # Ensure install directory and bin subdirectory exist- mkdir -p "$INSTALL_DIR/bin"-- # Copy Pulse binary to the correct location (/opt/pulse/bin/pulse)- # First, backup the old binary if it exists- if [[ -f "$INSTALL_DIR/bin/pulse" ]]; then- mv "$INSTALL_DIR/bin/pulse" "$INSTALL_DIR/bin/pulse.old" 2>/dev/null || true- fi-- if [[ -f "$TEMP_EXTRACT/bin/pulse" ]]; then- if ! cp "$TEMP_EXTRACT/bin/pulse" "$INSTALL_DIR/bin/pulse"; then- print_error "Failed to copy new binary to $INSTALL_DIR/bin/pulse"- # Try to restore old binary- if [[ -f "$INSTALL_DIR/bin/pulse.old" ]]; then- mv "$INSTALL_DIR/bin/pulse.old" "$INSTALL_DIR/bin/pulse"- fi+ archive_path=$(create_temp_archive_path "/tmp/pulse-${LATEST_RELEASE}-linux-${pulse_arch}") || {+ print_error "Failed to create temporary archive path"exit 1- fi- elif [[ -f "$TEMP_EXTRACT/pulse" ]]; then- # Fallback for old archives (pre-v4.3.1)- if ! cp "$TEMP_EXTRACT/pulse" "$INSTALL_DIR/bin/pulse"; then- print_error "Failed to copy new binary to $INSTALL_DIR/bin/pulse"- # Try to restore old binary- if [[ -f "$INSTALL_DIR/bin/pulse.old" ]]; then- mv "$INSTALL_DIR/bin/pulse.old" "$INSTALL_DIR/bin/pulse"- fi+ }+ archive_from_temp=true+ if ! download_release_archive "$LATEST_RELEASE" "$pulse_arch" "$archive_path"; then+ rm -f "$archive_path"exit 1fi- else- print_error "Pulse binary not found in archive"- # Try to restore old binary- if [[ -f "$INSTALL_DIR/bin/pulse.old" ]]; then- mv "$INSTALL_DIR/bin/pulse.old" "$INSTALL_DIR/bin/pulse"- fi- exit 1+ expected_release="$LATEST_RELEASE"fi-- # Verify the new binary was copied and is executable- if [[ ! -f "$INSTALL_DIR/bin/pulse" ]]; then- print_error "Binary installation failed - file not found after copy"- # Try to restore old binary- if [[ -f "$INSTALL_DIR/bin/pulse.old" ]]; then- mv "$INSTALL_DIR/bin/pulse.old" "$INSTALL_DIR/bin/pulse"++ # Detect and stop existing service after the archive is available but before replacing the binary.+ EXISTING_SERVICE=$(detect_service_name)+ if timeout 5 systemctl is-active --quiet "$EXISTING_SERVICE" 2>/dev/null; then+ print_info "Stopping existing Pulse service ($EXISTING_SERVICE)..."+ safe_systemctl stop "$EXISTING_SERVICE" || true+ sleep 2+ fi++ if ! install_pulse_archive "$archive_path" "$expected_release"; then+ if [[ "$archive_from_temp" == "true" ]]; then+ rm -f "$archive_path"fiexit 1fi- install_additional_agent_binaries "$LATEST_RELEASE" "$TEMP_EXTRACT"+ if [[ "$archive_from_temp" == "true" ]]; then+ rm -f "$archive_path"+ fi+ fi # End of SKIP_DOWNLOAD check+}- # Install all agent scripts- deploy_agent_scripts "$TEMP_EXTRACT"-- chmod +x "$INSTALL_DIR/bin/pulse"- chown -R pulse:pulse "$INSTALL_DIR"-- # Clean up old binary backup if everything succeeded- rm -f "$INSTALL_DIR/bin/pulse.old"-- # Create symlink in /usr/local/bin for PATH convenience- ln -sf "$INSTALL_DIR/bin/pulse" /usr/local/bin/pulse- print_success "Pulse binary installed to $INSTALL_DIR/bin/pulse"- print_success "Symlink created at /usr/local/bin/pulse"-- # Copy VERSION file if present- if [[ -f "$TEMP_EXTRACT/VERSION" ]]; then- cp "$TEMP_EXTRACT/VERSION" "$INSTALL_DIR/VERSION"- chown pulse:pulse "$INSTALL_DIR/VERSION"- fi-- # Verify the installed version matches what we expected- INSTALLED_VERSION=$("$INSTALL_DIR/bin/pulse" --version 2>/dev/null | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9\.]+)?' | head -1 || echo "unknown")- if [[ "$INSTALLED_VERSION" != "$LATEST_RELEASE" ]]; then- print_warn "Version verification issue: Expected $LATEST_RELEASE but binary reports $INSTALLED_VERSION"- print_info "This can happen if the binary wasn't properly replaced. Trying to fix..."-- # Force remove and recopy- rm -f "$INSTALL_DIR/bin/pulse"- if [[ -f "$ARCHIVE_PATH" ]]; then- # Re-extract and try again- TEMP_EXTRACT2="/tmp/pulse-extract2-$$"- mkdir -p "$TEMP_EXTRACT2"- tar -xzf "$ARCHIVE_PATH" -C "$TEMP_EXTRACT2"-- if [[ -f "$TEMP_EXTRACT2/bin/pulse" ]]; then- cp -f "$TEMP_EXTRACT2/bin/pulse" "$INSTALL_DIR/bin/pulse"- elif [[ -f "$TEMP_EXTRACT2/pulse" ]]; then- cp -f "$TEMP_EXTRACT2/pulse" "$INSTALL_DIR/bin/pulse"- fi+prefetch_pulse_archive_for_container() {+ local output_var="$1"+ local raw_arch=""+ local pulse_arch=""+ local archive_path=""- install_additional_agent_binaries "$LATEST_RELEASE" "$TEMP_EXTRACT2"+ resolve_target_release- deploy_agent_scripts "$TEMP_EXTRACT2"-- chmod +x "$INSTALL_DIR/bin/pulse"- chown -R pulse:pulse "$INSTALL_DIR"- rm -rf "$TEMP_EXTRACT2"-- # Check version again- INSTALLED_VERSION=$("$INSTALL_DIR/bin/pulse" --version 2>/dev/null | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9\.]+)?' | head -1 || echo "unknown")- if [[ "$INSTALLED_VERSION" == "$LATEST_RELEASE" ]]; then- print_success "Version issue resolved - now running $INSTALLED_VERSION"- else- print_warn "Version mismatch persists. You may need to restart the service or reboot."- fi- fi- else- print_success "Version verified: $INSTALLED_VERSION"- fi-- # Restore SELinux contexts for installed binaries (Fedora, RHEL, etc.)- restore_selinux_contexts+ raw_arch=$(uname -m)+ pulse_arch=$(detect_pulse_architecture "$raw_arch") || {+ print_error "Unsupported architecture for container install: $raw_arch"+ return 1+ }- # Cleanup- rm -rf "$TEMP_EXTRACT" "$ARCHIVE_PATH"- fi # End of SKIP_DOWNLOAD check+ print_info "Prefetching Pulse release archive on Proxmox host..."+ print_info "Detected architecture: $raw_arch ($pulse_arch)"++ archive_path=$(create_temp_archive_path "/tmp/pulse-${LATEST_RELEASE}-linux-${pulse_arch}-lxc") || {+ print_error "Failed to create temporary archive path"+ return 1+ }+ if ! download_release_archive "$LATEST_RELEASE" "$pulse_arch" "$archive_path"; then+ rm -f "$archive_path"+ return 1+ fi++ printf -v "$output_var" '%s' "$archive_path"+ return 0}copy_unified_agent_binaries_from_dir() {@@ -3934,6 +4228,24 @@ while [[ $# -gt 0 ]]; doFORCE_VERSION="$2"shift 2;;+ --archive)+ if [[ $# -lt 2 ]] || [[ -z "${2:-}" ]] || [[ "$2" =~ ^-- ]]; then+ print_error "--archive requires a local .tar.gz path"+ echo "Use --help for usage information"+ exit 1+ fi+ ARCHIVE_OVERRIDE="$2"+ shift 2+ ;;+ --archive=*)+ ARCHIVE_OVERRIDE="${1#*=}"+ if [[ -z "$ARCHIVE_OVERRIDE" ]]; then+ print_error "--archive requires a local .tar.gz path"+ echo "Use --help for usage information"+ exit 1+ fi+ shift+ ;;--in-container)IN_CONTAINER=true# Check if this is a Docker container (multiple detection methods)@@ -3968,6 +4280,7 @@ while [[ $# -gt 0 ]]; doecho " --rc, --pre Install latest prerelease preview version"echo " --stable Install latest stable version (default)"echo " --version VERSION Install specific version (e.g., v4.4.0-rc.1)"+ echo " --archive PATH Install from a local Pulse release tarball"echo " --source [BRANCH] Build and install from source (default: main)"echo " --enable-auto-updates Enable automatic stable updates (via systemd timer)"echo ""@@ -3986,6 +4299,11 @@ while [[ $# -gt 0 ]]; doesacdone+if [[ "$BUILD_FROM_SOURCE" == "true" ]] && [[ -n "$ARCHIVE_OVERRIDE" ]]; then+ print_error "--archive cannot be used with --source"+ exit 1+fi+auto_detect_container_environment# Export for use in download_pulse functiondiff --git a/scripts/installtests/install_sh_test.go b/scripts/installtests/install_sh_test.goindex e1ba228ba3..770e3500e4 100644--- a/scripts/installtests/install_sh_test.go+++ b/scripts/installtests/install_sh_test.go@@ -1201,6 +1201,7 @@ exit 1FORCE_VERSION=""FORCE_CHANNEL="rc"UPDATE_CHANNEL=""+` + extractRootInstallShellFunction(t, "resolve_latest_release_tag_for_channel") + `` + extractRootInstallShellFunction(t, "resolve_install_script_download_url") + `resolve_install_script_download_url`@@ -1244,6 +1245,62 @@ func TestBuildContainerInstallCommandPreservesForcedVersion(t *testing.T) {}}+func TestBuildContainerInstallCommandPassesArchiveToContainer(t *testing.T) {+ script := `+ FORCE_VERSION=""+ FORCE_CHANNEL=""+ UPDATE_CHANNEL=""+ auto_updates_flag=""+ BUILD_FROM_SOURCE="false"+ SOURCE_BRANCH="main"+ frontend_port="7655"+ container_archive_dest="/tmp/pulse-v6.0.0-rc.1-linux-amd64.tar.gz"+ CONFIG_DIR="` + t.TempDir() + `"+` + extractRootInstallShellFunction(t, "selected_update_channel") + `+` + extractRootInstallShellFunction(t, "build_container_install_command") + `+ build_container_install_command+ `++ out, err := exec.Command("bash", "-c", script).CombinedOutput()+ if err != nil {+ t.Fatalf("bash: %v\n%s", err, out)+ }++ got := strings.TrimSpace(string(out))+ want := "bash /tmp/install.sh --in-container --archive /tmp/pulse-v6.0.0-rc.1-linux-amd64.tar.gz"+ if got != want {+ t.Fatalf("install cmd = %q, want %q", got, want)+ }+}++func TestBuildContainerInstallCommandQuotesArchivePath(t *testing.T) {+ script := `+ FORCE_VERSION=""+ FORCE_CHANNEL=""+ UPDATE_CHANNEL=""+ auto_updates_flag=""+ BUILD_FROM_SOURCE="false"+ SOURCE_BRANCH="main"+ frontend_port="7655"+ container_archive_dest="/tmp/pulse archive-linux-amd64.tar.gz"+ CONFIG_DIR="` + t.TempDir() + `"+` + extractRootInstallShellFunction(t, "selected_update_channel") + `+` + extractRootInstallShellFunction(t, "build_container_install_command") + `+ build_container_install_command+ `++ out, err := exec.Command("bash", "-c", script).CombinedOutput()+ if err != nil {+ t.Fatalf("bash: %v\n%s", err, out)+ }++ got := strings.TrimSpace(string(out))+ want := `bash /tmp/install.sh --in-container --archive /tmp/pulse\ archive-linux-amd64.tar.gz`+ if got != want {+ t.Fatalf("install cmd = %q, want %q", got, want)+ }+}+func TestBuildContainerInstallCommandPreservesRCChannel(t *testing.T) {script := `FORCE_VERSION=""diff --git a/scripts/installtests/root_install_sh_test.go b/scripts/installtests/root_install_sh_test.goindex 10d0b1221c..af3bdb26c5 100644--- a/scripts/installtests/root_install_sh_test.go+++ b/scripts/installtests/root_install_sh_test.go@@ -26,6 +26,64 @@ func TestRootInstallScriptVersionFlagRequiresValue(t *testing.T) {}}+func TestRootInstallScriptArchiveFlagRequiresValue(t *testing.T) {+ scriptPath := filepath.Join("..", "..", "install.sh")++ cmd := exec.Command("bash", scriptPath, "--archive")+ out, err := cmd.CombinedOutput()+ if err == nil {+ t.Fatal("expected install.sh --archive without value to fail")+ }++ got := string(out)+ if !strings.Contains(got, "--archive requires a local .tar.gz path") {+ t.Fatalf("expected friendly archive missing-value error, got:\n%s", got)+ }+ if strings.Contains(got, "unbound variable") {+ t.Fatalf("expected guarded parser error, got shell failure:\n%s", got)+ }+}++func TestRootInstallScriptArchiveCannotBeUsedWithSource(t *testing.T) {+ scriptPath := filepath.Join("..", "..", "install.sh")++ cmd := exec.Command("bash", scriptPath, "--source", "--archive", "/tmp/pulse-v6.0.0-linux-amd64.tar.gz")+ out, err := cmd.CombinedOutput()+ if err == nil {+ t.Fatal("expected install.sh --source --archive to fail")+ }++ got := string(out)+ if !strings.Contains(got, "--archive cannot be used with --source") {+ t.Fatalf("expected archive/source conflict error, got:\n%s", got)+ }+}++func TestRootInstallScriptArchiveSupportContract(t *testing.T) {+ content, err := os.ReadFile(filepath.Join("..", "..", "install.sh"))+ if err != nil {+ t.Fatalf("read root install.sh: %v", err)+ }++ script := string(content)+ required := []string{+ `ARCHIVE_OVERRIDE="${PULSE_ARCHIVE_PATH:-}"`,+ `--archive PATH`,+ `resolve_archive_override()`,+ `infer_release_from_archive_name()`,+ `validate_pulse_binary_architecture()`,+ `prefetch_pulse_archive_for_container()`,+ `download_release_archive()`,+ `install_pulse_archive()`,+ `Archive version $inferred_release does not match requested version $FORCE_VERSION`,+ }+ for _, needle := range required {+ if !strings.Contains(script, needle) {+ t.Fatalf("install.sh missing archive support contract: %s", needle)+ }+ }+}+func TestRootInstallScriptAutoRegisterUsesSecureContractShape(t *testing.T) {content, err := os.ReadFile(filepath.Join("..", "..", "install.sh"))if err != nil {