mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-04-26 10:31:17 +00:00
Fix installer universal bundle fallback
This commit is contained in:
parent
1f0dfd60fc
commit
efb840deae
2 changed files with 73 additions and 78 deletions
90
install.sh
90
install.sh
|
|
@ -2724,17 +2724,9 @@ install_additional_agent_binaries() {
|
|||
return
|
||||
fi
|
||||
|
||||
local docker_targets=("linux-amd64" "linux-arm64" "linux-armv7")
|
||||
local host_targets=("linux-amd64" "linux-arm64" "linux-armv7" "linux-armv6" "linux-386" "darwin-amd64" "darwin-arm64" "windows-amd64" "windows-arm64" "windows-386")
|
||||
local unified_targets=("linux-amd64" "linux-arm64" "linux-armv7" "linux-armv6" "linux-386" "darwin-amd64" "darwin-arm64" "windows-amd64" "windows-arm64" "windows-386")
|
||||
|
||||
local docker_missing_targets=()
|
||||
for target in "${docker_targets[@]}"; do
|
||||
if [[ ! -f "$INSTALL_DIR/bin/pulse-docker-agent-$target" ]]; then
|
||||
docker_missing_targets+=("$target")
|
||||
fi
|
||||
done
|
||||
|
||||
local host_missing_targets=()
|
||||
for target in "${host_targets[@]}"; do
|
||||
if [[ "$target" == windows-* ]]; then
|
||||
|
|
@ -2761,83 +2753,25 @@ install_additional_agent_binaries() {
|
|||
fi
|
||||
done
|
||||
|
||||
if [[ ${#docker_missing_targets[@]} -eq 0 ]] && [[ ${#host_missing_targets[@]} -eq 0 ]] && [[ ${#unified_missing_targets[@]} -eq 0 ]]; then
|
||||
if [[ ${#host_missing_targets[@]} -eq 0 ]] && [[ ${#unified_missing_targets[@]} -eq 0 ]]; then
|
||||
if [[ $local_host_installed -eq 1 ]]; then
|
||||
print_success "Additional host agent binaries installed"
|
||||
fi
|
||||
if [[ $local_unified_installed -eq 1 ]]; then
|
||||
print_success "Unified agent binaries installed"
|
||||
fi
|
||||
return
|
||||
fi
|
||||
|
||||
local universal_url="https://github.com/$GITHUB_REPO/releases/download/$version/pulse-${version}.tar.gz"
|
||||
local universal_tar="/tmp/pulse-universal-${version}.tar.gz"
|
||||
|
||||
print_info "Downloading universal agent bundle for cross-architecture support..."
|
||||
|
||||
if command -v curl >/dev/null 2>&1; then
|
||||
if ! curl -fsSL --connect-timeout 10 --max-time 300 -o "$universal_tar" "$universal_url"; then
|
||||
print_warn "Failed to download universal agent bundle"
|
||||
rm -f "$universal_tar"
|
||||
return
|
||||
fi
|
||||
elif command -v wget >/dev/null 2>&1; then
|
||||
if ! wget -q --timeout=300 -O "$universal_tar" "$universal_url"; then
|
||||
print_warn "Failed to download universal agent bundle"
|
||||
rm -f "$universal_tar"
|
||||
return
|
||||
fi
|
||||
else
|
||||
print_warn "Cannot download universal agent bundle (curl or wget not available)"
|
||||
return
|
||||
fi
|
||||
|
||||
local temp_dir
|
||||
temp_dir=$(mktemp -d -t pulse-universal-XXXXXX)
|
||||
if ! tar -xzf "$universal_tar" -C "$temp_dir"; then
|
||||
print_warn "Failed to extract universal agent bundle"
|
||||
rm -f "$universal_tar"
|
||||
rm -rf "$temp_dir"
|
||||
return
|
||||
fi
|
||||
|
||||
local docker_installed=0
|
||||
local bundle_host_installed=0
|
||||
|
||||
# Install Docker agent binaries
|
||||
for agent_file in "$temp_dir"/bin/pulse-docker-agent-linux-*; do
|
||||
if [[ -f "$agent_file" ]]; then
|
||||
local base
|
||||
base=$(basename "$agent_file")
|
||||
cp -f "$agent_file" "$INSTALL_DIR/bin/$base"
|
||||
cp -f "$agent_file" "$INSTALL_DIR/$base"
|
||||
chmod +x "$INSTALL_DIR/bin/$base" "$INSTALL_DIR/$base"
|
||||
chown pulse:pulse "$INSTALL_DIR/bin/$base" "$INSTALL_DIR/$base"
|
||||
docker_installed=1
|
||||
fi
|
||||
done
|
||||
|
||||
# Install host agent binaries (preserve symlinks for Windows targets)
|
||||
if copy_host_agent_binaries_from_dir "$temp_dir"; then
|
||||
bundle_host_installed=1
|
||||
fi
|
||||
|
||||
# Install unified agent binaries (preserve symlinks for Windows targets)
|
||||
local bundle_unified_installed=0
|
||||
if copy_unified_agent_binaries_from_dir "$temp_dir"; then
|
||||
bundle_unified_installed=1
|
||||
fi
|
||||
|
||||
if [[ $docker_installed -eq 1 ]]; then
|
||||
print_success "Additional Docker agent binaries installed"
|
||||
fi
|
||||
if [[ $local_host_installed -eq 1 || $bundle_host_installed -eq 1 ]]; then
|
||||
if [[ $local_host_installed -eq 1 ]]; then
|
||||
print_success "Additional host agent binaries installed"
|
||||
fi
|
||||
if [[ $local_unified_installed -eq 1 || $bundle_unified_installed -eq 1 ]]; then
|
||||
if [[ $local_unified_installed -eq 1 ]]; then
|
||||
print_success "Unified agent binaries installed"
|
||||
fi
|
||||
if [[ $docker_installed -eq 0 ]] && [[ $local_host_installed -eq 0 ]] && [[ $bundle_host_installed -eq 0 ]] && [[ $local_unified_installed -eq 0 ]] && [[ $bundle_unified_installed -eq 0 ]]; then
|
||||
print_warn "No agent binaries found in universal bundle"
|
||||
fi
|
||||
|
||||
rm -f "$universal_tar"
|
||||
rm -rf "$temp_dir"
|
||||
print_info "Skipping eager cross-architecture agent bundle download during install"
|
||||
print_info "Missing host and unified agent binaries will be fetched on demand when requested"
|
||||
return 0
|
||||
}
|
||||
|
||||
deploy_agent_scripts() {
|
||||
|
|
|
|||
|
|
@ -205,6 +205,65 @@ test_installer_runs_when_streamed_over_stdin() {
|
|||
return 0
|
||||
}
|
||||
|
||||
test_install_additional_agent_binaries_copies_local_binaries_without_network() {
|
||||
(
|
||||
load_installer
|
||||
|
||||
local tmpdir source_dir
|
||||
tmpdir="$(mktemp -d)"
|
||||
source_dir="${tmpdir}/source"
|
||||
INSTALL_DIR="${tmpdir}/opt/pulse"
|
||||
|
||||
mkdir -p "${source_dir}/bin" "${INSTALL_DIR}/bin"
|
||||
printf 'host-agent\n' > "${source_dir}/bin/pulse-host-agent-linux-arm64"
|
||||
printf 'unified-agent\n' > "${source_dir}/bin/pulse-agent-linux-arm64"
|
||||
chmod +x "${source_dir}/bin/pulse-host-agent-linux-arm64" "${source_dir}/bin/pulse-agent-linux-arm64"
|
||||
|
||||
local curl_calls=0
|
||||
local wget_calls=0
|
||||
|
||||
chown() { :; }
|
||||
curl() { curl_calls=$((curl_calls + 1)); return 99; }
|
||||
wget() { wget_calls=$((wget_calls + 1)); return 99; }
|
||||
|
||||
install_additional_agent_binaries "v5.1.99" "${source_dir}"
|
||||
|
||||
[[ -x "${INSTALL_DIR}/bin/pulse-host-agent-linux-arm64" ]]
|
||||
[[ -x "${INSTALL_DIR}/bin/pulse-agent-linux-arm64" ]]
|
||||
[[ "${curl_calls}" -eq 0 ]]
|
||||
[[ "${wget_calls}" -eq 0 ]]
|
||||
|
||||
rm -rf "${tmpdir}"
|
||||
)
|
||||
}
|
||||
|
||||
test_install_additional_agent_binaries_skips_network_when_local_extras_are_missing() {
|
||||
(
|
||||
load_installer
|
||||
|
||||
local tmpdir source_dir
|
||||
tmpdir="$(mktemp -d)"
|
||||
source_dir="${tmpdir}/source"
|
||||
INSTALL_DIR="${tmpdir}/opt/pulse"
|
||||
|
||||
mkdir -p "${source_dir}/bin" "${INSTALL_DIR}/bin"
|
||||
|
||||
local curl_calls=0
|
||||
local wget_calls=0
|
||||
|
||||
chown() { :; }
|
||||
curl() { curl_calls=$((curl_calls + 1)); return 99; }
|
||||
wget() { wget_calls=$((wget_calls + 1)); return 99; }
|
||||
|
||||
install_additional_agent_binaries "v5.1.99" "${source_dir}"
|
||||
|
||||
[[ "${curl_calls}" -eq 0 ]]
|
||||
[[ "${wget_calls}" -eq 0 ]]
|
||||
|
||||
rm -rf "${tmpdir}"
|
||||
)
|
||||
}
|
||||
|
||||
main() {
|
||||
assert_success "infer_release_from_archive_name parses prerelease tarballs" test_infer_release_from_archive_name_supports_prerelease
|
||||
assert_success "download_pulse installs from local archive without network" test_download_pulse_installs_from_local_archive_without_network
|
||||
|
|
@ -212,6 +271,8 @@ main() {
|
|||
assert_success "wrong-arch archives fail before replacing the installed binary" test_install_pulse_archive_rejects_mismatched_arch_without_replacing_existing_binary
|
||||
assert_success "parse_args rejects archive with source builds" test_parse_args_rejects_archive_with_source
|
||||
assert_success "installer supports curl-pipe execution via bash stdin" test_installer_runs_when_streamed_over_stdin
|
||||
assert_success "install_additional_agent_binaries copies local extras without network" test_install_additional_agent_binaries_copies_local_binaries_without_network
|
||||
assert_success "install_additional_agent_binaries skips network when extras are missing" test_install_additional_agent_binaries_skips_network_when_local_extras_are_missing
|
||||
|
||||
if (( failures > 0 )); then
|
||||
echo "Total failures: ${failures}" >&2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue