The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
#!/bin/sh
# Downloads the Vector build that Beacon's Linux packages and archives ship, checks it, and stages
# it where goreleaser picks it up.
#
# packaging/linux/fetch-vector.sh [out-dir] [arch...]
#
# out-dir defaults to cli/beacon/release-vector and arch to "amd64 arm64". Each binary lands at
# <out-dir>/linux_<arch>/beacon-vector. The .deb and .rpm install it as /opt/beacon/bin/vector;
# the release archive keeps the beacon-vector name so unpacking it into a directory on PATH never
# shadows a Vector the user already has.
#
# The musl build, not the gnu one. The gnu build links glibc dynamically, and every Linux binary
# Beacon ships is static so it runs on stripped and custom-built hosts without caring which libc
# they carry. The script fails unless the binary has no program interpreter.
#
# Set VECTOR_VERSION to change the version, and run packaging/linux/validate-vector-packs.sh
# against the result before shipping it. 0.56.0 matches the signed macOS package. Newer releases
# break the generated packs, which take destinations and credentials from ${VAR}: 0.57 stops
# expanding the ${VAR:-default} form, and 0.58 stops expanding ${VAR} at all unless Vector runs
# with --dangerously-allow-env-var-interpolation. (Beacon Cloud's connect is unaffected because
# it writes literal values.)
#
# The archives are checked against packaging/vector/vector-<version>-SHA256SUMS, committed in this
# repository, not against a checksum file fetched from the same host as the archives: the binary
# is signed into Beacon's packages and runs as the root forwarder, so a compromised download host
# must not be able to supply both. A new version needs its pinned checksums committed first.
set -eu
VECTOR_VERSION="${VECTOR_VERSION:-0.56.0}"
ROOT_DIR="$(CDPATH='' cd -- "$(dirname -- "$0")/../.." && pwd)"
OUT_DIR="${1:-$ROOT_DIR/cli/beacon/release-vector}"
[ "$#" -gt 0 ] && shift
ARCHES="${*:-amd64 arm64}"
BASE_URL="https://packages.timber.io/vector/${VECTOR_VERSION}"
for tool in curl tar; do
command -v "$tool" >/dev/null 2>&1 || { echo "fetch-vector: $tool is required" >&2; exit 1; }
done
command -v readelf >/dev/null 2>&1 || command -v file >/dev/null 2>&1 || {
echo "fetch-vector: readelf or file is required to check the binary is static" >&2; exit 1; }
if command -v sha256sum >/dev/null 2>&1; then
sha256_check() { sha256sum -c -; }
else
sha256_check() { shasum -a 256 -c -; }
fi
work="$(mktemp -d)"
trap 'rm -rf "$work"' EXIT INT TERM
sums="vector-${VECTOR_VERSION}-SHA256SUMS"
pinned="$ROOT_DIR/packaging/vector/$sums"
[ -f "$pinned" ] || { echo "fetch-vector: no pinned checksums at $pinned; commit them for Vector $VECTOR_VERSION first" >&2; exit 1; }
cp "$pinned" "$work/$sums"
for arch in $ARCHES; do
case "$arch" in
amd64) triple=x86_64-unknown-linux-musl ;;
arm64) triple=aarch64-unknown-linux-musl ;;
*) echo "fetch-vector: unsupported arch $arch" >&2; exit 1 ;;
esac
archive="vector-${VECTOR_VERSION}-${triple}.tar.gz"
curl -fsSL --retry 3 -o "$work/$archive" "$BASE_URL/$archive"
line="$(awk -v a="$archive" '$2 == a { print }' "$work/$sums")"
[ -n "$line" ] || { echo "fetch-vector: no pinned checksum for $archive in $pinned" >&2; exit 1; }
(cd "$work" && printf '%s\n' "$line" | sha256_check)
mkdir -p "$work/$arch"
tar -xzf "$work/$archive" -C "$work/$arch"
bin="$(find "$work/$arch" -path '*/bin/vector' -type f | head -n 1)"
[ -n "$bin" ] || { echo "fetch-vector: no bin/vector in $archive" >&2; exit 1; }
# A dynamic binary has an INTERP program header and a static one does not. The headers must be
# read successfully and include a LOAD segment first, or a file readelf cannot parse would pass.
# Without readelf (macOS), file(1) has to say static outright; anything else fails.
if command -v readelf >/dev/null 2>&1; then
headers="$(readelf -lW "$bin")" || { echo "fetch-vector: readelf could not read $bin" >&2; exit 1; }
case "$headers" in
*LOAD*) ;;
*) echo "fetch-vector: no program headers in $bin" >&2; exit 1 ;;
esac
case "$headers" in
*INTERP*)
echo "fetch-vector: $archive is dynamically linked; Beacon ships only static Linux binaries" >&2
exit 1 ;;
esac
else
kind="$(file -b "$bin")"
case "$kind" in
ELF*"static-pie linked"*|ELF*"statically linked"*) ;;
*) echo "fetch-vector: $archive is not a static ELF binary: $kind" >&2; exit 1 ;;
esac
fi
mkdir -p "$OUT_DIR/linux_$arch"
cp "$bin" "$OUT_DIR/linux_$arch/beacon-vector"
chmod 755 "$OUT_DIR/linux_$arch/beacon-vector"
echo "staged $OUT_DIR/linux_$arch/beacon-vector (Vector $VECTOR_VERSION, $triple, static)"
done