Big update

This commit is contained in:
p2913020
2026-06-29 13:00:24 -04:00
parent 81279ec63c
commit e10c291958

View File

@@ -156,20 +156,99 @@ install_agent_package_manager() {
}
install_agent_binary() {
log "Installing Zabbix Agent 2 from pre-compiled binary..."
log "Installing Zabbix Agent 2 from direct .deb package (bookworm arm64)..."
# Zabbix does not publish static binary tarballs for ARM architectures.
# Instead, we fetch the .deb package directly from the debian-arm64 bookworm pool.
# Agent 2 is a Go binary with minimal libc dependencies, so installing a bookworm
# .deb on bullseye works reliably.
local deb_path="/tmp/zabbix_agent2.deb"
local pool_base="https://repo.zabbix.com/zabbix/7.0/debian-arm64/pool/main/z/zabbix"
# Try multiple URL patterns for the .deb package
local deb_urls=(
"${pool_base}/zabbix-agent2_${ZABBIX_VERSION}-1+debian12_arm64.deb"
"${pool_base}/zabbix-agent2_${ZABBIX_VERSION}-1%2Bdebian12_arm64.deb"
)
local downloaded=false
for url in "${deb_urls[@]}"; do
log "Trying: ${url}"
if wget -q "${url}" -O "${deb_path}" 2>/dev/null; then
if dpkg-deb --info "${deb_path}" >/dev/null 2>&1; then
downloaded=true
break
fi
fi
if curl -sfL "${url}" -o "${deb_path}" 2>/dev/null; then
if dpkg-deb --info "${deb_path}" >/dev/null 2>&1; then
downloaded=true
break
fi
fi
rm -f "${deb_path}"
done
# Fallback: try the CDN static tarball path (may work for some versions)
if [ "${downloaded}" = false ]; then
local tarball_url="https://cdn.zabbix.com/zabbix/binaries/stable/7.0/${ZABBIX_VERSION}/zabbix_agent2-${ZABBIX_VERSION}-${TARBALL_ARCH}-static.tar.gz"
local tarball_path="/tmp/zabbix_agent2.tar.gz"
log "Downloading from: ${tarball_url}"
if ! wget -q "${tarball_url}" -O "${tarball_path}" 2>/dev/null && \
! curl -sL "${tarball_url}" -o "${tarball_path}" 2>/dev/null; then
log "ERROR: Failed to download Zabbix Agent 2 binary."
log " URL: ${tarball_url}"
log " You may need to check https://www.zabbix.com/download for the correct ARM binary."
log "Trying CDN tarball: ${tarball_url}"
if wget -q "${tarball_url}" -O "${tarball_path}" 2>/dev/null || \
curl -sfL "${tarball_url}" -o "${tarball_path}" 2>/dev/null; then
# Verify it's actually a gzip file
if file "${tarball_path}" 2>/dev/null | grep -q gzip; then
install_from_tarball "${tarball_path}"
return 0
fi
fi
rm -f "${tarball_path}"
log "ERROR: Failed to download Zabbix Agent 2 for ${ARCH_LABEL}."
log " No static binary or .deb package found."
log " Options:"
log " 1. Upgrade to Debian 12 (Bookworm) and re-run this script"
log " 2. Manually download from https://www.zabbix.com/download"
log " 3. Install from Debian's own repos: apt install zabbix-agent2"
exit 1
fi
# Install the .deb package
log "Installing .deb package..."
mkdir -p /etc/zabbix
mkdir -p /var/log/zabbix
mkdir -p /var/run/zabbix
# Create zabbix user if it doesn't exist
if ! id -u zabbix &>/dev/null; then
useradd -r -s /sbin/nologin -d /var/lib/zabbix -M zabbix
fi
# Install with --force-depends to handle minor dependency version mismatches
# between bookworm and bullseye
if ! dpkg -i --force-depends "${deb_path}" 2>&1; then
log "dpkg install had issues, attempting to fix dependencies..."
apt-get install -f -y 2>/dev/null || true
fi
rm -f "${deb_path}"
# Verify the binary is in place
if command -v zabbix_agent2 >/dev/null 2>&1 || [ -f /usr/sbin/zabbix_agent2 ]; then
log "Package installation complete."
chown -R zabbix:zabbix /var/log/zabbix /var/run/zabbix 2>/dev/null || true
else
log "ERROR: zabbix_agent2 binary not found after package install."
exit 1
fi
}
install_from_tarball() {
local tarball_path="$1"
log "Extracting tarball..."
# Create directories
mkdir -p "${INSTALL_DIR}/bin"
mkdir -p /etc/zabbix
@@ -182,7 +261,7 @@ install_agent_binary() {
# Find the binary
local agent_bin
agent_bin=$(find "${INSTALL_DIR}" -name "zabbix_agent2" -type f | head -1)
agent_bin=$(find "${INSTALL_DIR}" -name "zabbix_agent2" -type f 2>/dev/null | head -1)
if [ -z "${agent_bin}" ]; then
log "ERROR: Could not find zabbix_agent2 binary in extracted archive."
exit 1
@@ -200,9 +279,6 @@ install_agent_binary() {
chown -R zabbix:zabbix /var/log/zabbix /var/run/zabbix
# Set config path for binary installs
AGENT_CONF="/etc/zabbix/zabbix_agent2.conf"
# Create systemd service
create_systemd_service