From 2541e38ac8598eb633b6cae414749424aa876119 Mon Sep 17 00:00:00 2001 From: John Gaunt Date: Sat, 19 Nov 2022 15:58:04 -0500 Subject: [PATCH] Updated variable name, updated for Rocky 9 and updated zabbix urls --- zabbix_agent.sh | 55 +++++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/zabbix_agent.sh b/zabbix_agent.sh index 20df17b..e6685d7 100644 --- a/zabbix_agent.sh +++ b/zabbix_agent.sh @@ -18,9 +18,9 @@ fi OS=$(hostnamectl | awk '/Operating System/ {print $3}') VM=$(hostnamectl | awk '/Virtualization/ {print $2}') if [ ${OS} == 'Ubuntu' ]; then - OS_VER=$(hostnamectl | awk '/Operating System/ {print $4}') + OS_VERSION=$(hostnamectl | awk '/Operating System/ {print $4}') else - OS_VER=$(hostnamectl | awk '/Operating System/ {print $5}') + OS_VERSION=$(hostnamectl | awk '/Operating System/ {print $5}') fi if [ "${VM}" == "vmware" ]; then @@ -34,17 +34,17 @@ ZABBIX_SERVER="10.0.10.16" if [ ${OS} == 'Debian' ]; then # Install the repository configuration package. This package contains apt (software package manager) configuration files. - if [[ ${OS_VER} =~ ^9.* ]]; then - wget -P /tmp/ https://repo.zabbix.com/zabbix/6.0/debian/pool/main/z/zabbix-release/zabbix-release_6.0-1+debian9_all.deb - dpkg -i /tmp/zabbix-release_6.0-1+debian9_all.deb + if [[ ${OS_VERSION} =~ ^9.* ]]; then + wget -P /tmp/ https://repo.zabbix.com/zabbix/6.0/debian/pool/main/z/zabbix-release/zabbix-release_6.0-4+debian9_all.deb + dpkg -i /tmp/zabbix-release_6.0-4+debian9_all.deb fi - if [[ ${OS_VER} =~ ^10.* ]]; then - wget -P /tmp/ https://repo.zabbix.com/zabbix/6.0/debian/pool/main/z/zabbix-release/zabbix-release_6.0-1+debian10_all.deb - dpkg -i /tmp/zabbix-release_6.0-1+debian10_all.deb + if [[ ${OS_VERSION} =~ ^10.* ]]; then + wget -P /tmp/ https://repo.zabbix.com/zabbix/6.0/debian/pool/main/z/zabbix-release/zabbix-release_6.0-4+debian10_all.deb + dpkg -i /tmp/zabbix-release_6.0-4+debian10_all.deb fi - if [[ ${OS_VER} =~ ^11.* ]]; then - wget -P /tmp/ https://repo.zabbix.com/zabbix/6.0/debian/pool/main/z/zabbix-release/zabbix-release_6.0-1+debian11_all.deb - dpkg -i /tmp/zabbix-release_6.0-1+debian11_all.deb + if [[ ${OS_VERSION} =~ ^11.* ]]; then + wget -P /tmp/ https://repo.zabbix.com/zabbix/6.0/debian/pool/main/z/zabbix-release/zabbix-release_6.0-4+debian11_all.deb + dpkg -i /tmp/zabbix-release_6.0-4+debian11_all.deb fi # create missing directory mkdir /etc/zabbix/zabbix_agentd.conf.d @@ -58,38 +58,43 @@ if [ ${OS} == 'Debian' ]; then elif [ ${OS} == 'Ubuntu' ]; then # Install the repository configuration package. This package contains apt (software package manager) configuration files. - if [[ ${OS_VER} =~ 20.04 ]]; then - wget -P /tmp/ https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-1+ubuntu20.04_all.deb - dpkg -i /tmp/zabbix-release_6.0-1+ubuntu20.04_all.deb + if [[ ${OS_VERSION} =~ 20.04 ]]; then + wget -P /tmp/ https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-4+ubuntu20.04_all.deb + dpkg -i /tmp/zabbix-release_6.0-4+ubuntu20.04_all.deb fi - if [[ ${OS_VER} =~ 22.04 ]]; then - wget -P /tmp/ https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-2+ubuntu22.04_all.deb - dpkg -i /tmp/zabbix-release_6.0-2+ubuntu22.04_all.deb + if [[ ${OS_VERSION} =~ 22.04 ]]; then + wget -P /tmp/ https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-4+ubuntu22.04_all.deb + dpkg -i /tmp/zabbix-release_6.0-4+ubuntu22.04_all.deb fi # update the cache apt update # install the agent apt install -y zabbix-agent -elif [ ${OS} == 'CentOS' ]; then +elif [ ${OS} == 'CentOS' ] || [ "${OS}" == "Rocky" ]; then # Install the repository configuration package. This package contains yum (software package manager) configuration files. - if [ ${OS_VER} == 7 ]; then - rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/7/x86_64/zabbix-release-6.0-1.el7.noarch.rpm + if [ ${OS_VERSION} == 7 ]; then + rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/7/x86_64/zabbix-release-6.0-4.el7.noarch.rpm yum clean all yum install -y zabbix-agent fi - if [ ${OS_VER} == 8 ]; then - rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-1.el8.noarch.rpm + if [ ${OS_VERSION} == 8 ]; then + rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-4.el8.noarch.rpm dnf clean all dnf install -y zabbix-agent fi + if [ "${OS_VERSION}" == "9.0" ]; then + # zabbix is suppleied via the EPEL Repo + #rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/9/x86_64/zabbix-release-6.0-4.el9.noarch.rpm + #dnf clean all + dnf install -y zabbix-agent + fi cat << EOF >> /etc/firewalld/services/zabbix-agent.xml zabbix agent zabbix agent - EOF sleep 5 @@ -98,8 +103,8 @@ EOF else echo "You are running an unsupported OS" - echo "Support OSes: Debian 9/10/11, Ubuntu 20.04/22.04, CentOS 7" - echo "Your OS: ${OS} ${OS_VER}" + echo "Support OSes: Debian 9/10/11, Ubuntu 20.04/22.04, CentOS 7/8, Rocky 9 with EPEL" + echo "Your OS: ${OS} ${OS_VERSION}" exit fi