From 3704c74f83a120ea83281adf3be96fcd85f61a64 Mon Sep 17 00:00:00 2001 From: p2913020 Date: Mon, 29 Jun 2026 12:45:14 -0400 Subject: [PATCH] updated --- .../deploy_zabbix_agent_linux_arm.sh | 65 +++++++++++++++++-- 1 file changed, 58 insertions(+), 7 deletions(-) diff --git a/zabbix-autoregister/deploy_zabbix_agent_linux_arm.sh b/zabbix-autoregister/deploy_zabbix_agent_linux_arm.sh index af4144c..5b97e7c 100644 --- a/zabbix-autoregister/deploy_zabbix_agent_linux_arm.sh +++ b/zabbix-autoregister/deploy_zabbix_agent_linux_arm.sh @@ -10,7 +10,7 @@ set -euo pipefail ZABBIX_SERVER="zabbix.snarfnet.net" -ZABBIX_VERSION="7.0.0" +ZABBIX_VERSION="7.0.27" PSK_IDENTITY="PSK_autoregister" PSK_FILE="/etc/zabbix/zabbix_agent2.psk" AGENT_CONF="/etc/zabbix/zabbix_agent2.conf" @@ -61,17 +61,68 @@ install_agent_package_manager() { case "${OS_ID}" in debian|ubuntu|raspbian) log "Installing via apt (Debian/Ubuntu/Raspbian)..." - # Determine arch string for the repo local dpkg_arch dpkg_arch=$(dpkg --print-architecture) - wget -q "https://repo.zabbix.com/zabbix/7.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest+ubuntu_all.deb" -O /tmp/zabbix-release.deb 2>/dev/null || \ - wget -q "https://repo.zabbix.com/zabbix/7.0/debian/pool/main/z/zabbix-release/zabbix-release_latest+debian${OS_VERSION}_all.deb" -O /tmp/zabbix-release.deb 2>/dev/null || true + # Zabbix provides separate repos for ARM architectures: + # - debian-arm64 / ubuntu-arm64 for aarch64 + # - raspbian for armhf (Raspberry Pi OS) + # The standard debian/ubuntu repos only carry amd64. + local repo_distro="" + case "${dpkg_arch}" in + arm64) + if [ "${OS_ID}" = "ubuntu" ]; then + repo_distro="ubuntu-arm64" + else + repo_distro="debian-arm64" + fi + ;; + armhf) + repo_distro="raspbian" + ;; + *) + log "Unexpected dpkg arch '${dpkg_arch}' on ARM script. Falling back to binary..." + install_agent_binary + return 0 + ;; + esac + + # Determine release codename (e.g. bullseye, bookworm, jammy) + local codename="" + if [ -f /etc/os-release ]; then + codename=$(. /etc/os-release && echo "${VERSION_CODENAME:-}") + fi + if [ -z "${codename}" ]; then + log "Could not determine release codename. Falling back to binary..." + install_agent_binary + return 0 + fi + + # Disable defunct backports repos to prevent apt-get update 404 errors (Debian EOL releases) + local backports_list + backports_list=$(grep -rl 'backports' /etc/apt/sources.list /etc/apt/sources.list.d/ 2>/dev/null || true) + if [ -n "${backports_list}" ]; then + log "Disabling defunct backports repositories to avoid 404 errors..." + for f in ${backports_list}; do + sed -i '/backports/s/^[^#]/#&/' "${f}" + done + fi + + # Download and install the Zabbix release package for the ARM-specific repo + local release_url="https://repo.zabbix.com/zabbix/7.0/${repo_distro}/pool/main/z/zabbix-release/zabbix-release_latest+${OS_ID}${OS_VERSION}_all.deb" + log "Adding Zabbix repository: ${repo_distro} (${codename})" + log "Release package URL: ${release_url}" + + if wget -q "${release_url}" -O /tmp/zabbix-release.deb 2>/dev/null || \ + curl -sL "${release_url}" -o /tmp/zabbix-release.deb 2>/dev/null; then - if [ -f /tmp/zabbix-release.deb ]; then dpkg -i /tmp/zabbix-release.deb - apt-get update - apt-get install -y zabbix-agent2 && { rm -f /tmp/zabbix-release.deb; return 0; } + apt-get update -o Acquire::AllowInsecureRepositories=false 2>&1 | grep -v "^W:" || true + if apt-get install -y zabbix-agent2; then + rm -f /tmp/zabbix-release.deb + log "Package installation successful." + return 0 + fi fi log "Package manager install failed, falling back to binary tarball..."