updated
This commit is contained in:
@@ -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..."
|
||||
|
||||
Reference in New Issue
Block a user