Added checks for used external commands
This commit is contained in:
parent
054b67b1cc
commit
8c18737d10
@ -49,27 +49,44 @@ if [[ $EUID -ne 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
_info "Checking dependencies ..."
|
||||
if [ -x "$(command -v sed)" ]; then _info "sed - OK"; else _error "sed - MISSING" ; exit 1 ; fi
|
||||
if [ -x "$(command -v hostname)" ]; then _info "hostname - OK"; else _error "hostname - MISSING" ; exit 1 ; fi
|
||||
if [ -x "$(command -v ip)" ]; then _info "ip - OK"; else _error "ip - MISSING" ; exit 1 ; fi
|
||||
|
||||
# Download and install the Zabbix agent
|
||||
if [[ "$OS" == *"CentOS"* ]]; then
|
||||
if [ -x "$(command -v rpm)" ]; then _info "rpm - OK"; else _error "rpm - MISSING" ; exit 1 ; fi
|
||||
if [ -x "$(command -v yum)" ]; then _info "yum - OK"; else _error "yum - MISSING" ; exit 1 ; fi
|
||||
|
||||
if [[ "$VERSION" == "6"* ]]; then
|
||||
if [ -x "$(command -v service)" ]; then _info "service - OK"; else _error "service - MISSING" ; exit 1 ; fi
|
||||
if [ -x "$(command -v chkconfig)" ]; then _info "chkconfig - OK"; else _error "chkconfig - MISSING" ; exit 1 ; fi
|
||||
|
||||
_info "Downloading and installing Zabbix repositories ..."
|
||||
rpm -Uvh https://repo.zabbix.com/zabbix/6.4/rhel/6/x86_64/zabbix-release-6.4-1.el6.noarch.rpm &>> "$LOG_FILE"
|
||||
yum clean all &>> "$LOG_FILE"
|
||||
_info "Installing Zabbix Agent 2 ..."
|
||||
yum install zabbix-agent2 zabbix-agent2-plugin-* -y &>> "$LOG_FILE"
|
||||
elif [[ "$VERSION" == "7"* ]]; then
|
||||
if [ -x "$(command -v systemctl)" ]; then _info "systemctl - OK"; else _error "systemctl - MISSING" ; exit 1 ; fi
|
||||
|
||||
_info "Downloading and installing Zabbix repositories ..."
|
||||
rpm -Uvh https://repo.zabbix.com/zabbix/6.4/rhel/7/x86_64/zabbix-release-6.4-1.el7.noarch.rpm &>> "$LOG_FILE"
|
||||
yum clean all &>> "$LOG_FILE"
|
||||
_info "Installing Zabbix Agent 2 ..."
|
||||
yum install zabbix-agent2 zabbix-agent2-plugin-* -y &>> "$LOG_FILE"
|
||||
elif [[ "$VERSION" == "8"* ]]; then
|
||||
if [ -x "$(command -v systemctl)" ]; then _info "systemctl - OK"; else _error "systemctl - MISSING" ; exit 1 ; fi
|
||||
|
||||
_info "Downloading and installing Zabbix repositories ..."
|
||||
rpm -Uvh https://repo.zabbix.com/zabbix/6.4/rhel/8/x86_64/zabbix-release-6.4-1.el8.noarch.rpm &>> "$LOG_FILE"
|
||||
dnf clean all &>> "$LOG_FILE"
|
||||
_info "Installing Zabbix Agent 2 ..."
|
||||
dnf install zabbix-agent2 zabbix-agent2-plugin-* -y &>> "$LOG_FILE"
|
||||
elif [[ "$VERSION" == "9"* ]]; then
|
||||
if [ -x "$(command -v systemctl)" ]; then _info "systemctl - OK"; else _error "systemctl - MISSING" ; exit 1 ; fi
|
||||
|
||||
_info "Downloading and installing Zabbix repositories ..."
|
||||
sed -i '/\[epel\]/a excludepkgs=Zabbix*' /etc/yum.repos.d/epel.repo &>> "$LOG_FILE"
|
||||
rpm -Uvh https://repo.zabbix.com/zabbix/6.4/rhel/9/x86_64/zabbix-release-6.4-1.el9.noarch.rpm &>> "$LOG_FILE"
|
||||
@ -81,6 +98,11 @@ if [[ "$OS" == *"CentOS"* ]]; then
|
||||
exit 1
|
||||
fi
|
||||
elif [[ "$OS" == *"Debian"* ]]; then
|
||||
if [ -x "$(command -v wget)" ]; then _info "wget - OK"; else _error "wget - MISSING" ; exit 1 ; fi
|
||||
if [ -x "$(command -v dpkg)" ]; then _info "dpkg - OK"; else _error "dpkg - MISSING" ; exit 1 ; fi
|
||||
if [ -x "$(command -v apt)" ]; then _info "apt - OK"; else _error "apt - MISSING" ; exit 1 ; fi
|
||||
if [ -x "$(command -v systemctl)" ]; then _info "systemctl - OK"; else _error "systemctl - MISSING" ; exit 1 ; fi
|
||||
|
||||
if [[ "$VERSION" == "9"* ]]; then
|
||||
_info "Downloading Zabbix repositories package ..."
|
||||
wget https://repo.zabbix.com/zabbix/6.4/debian/pool/main/z/zabbix-release/zabbix-release_6.4-1+debian9_all.deb &>> "$LOG_FILE"
|
||||
|
Loading…
Reference in New Issue
Block a user