#!/bin/bash
mkdir -p /data/service/
#mv /tmp/zabbix-3.2.6.tar.gz /data/service/
#mv /data/service/zabbix-3.2.6.tar.gz /data/service
cd /data/service/
#sudo sed -i "s/SELINUX=configure/SELINUX=disabled/g" /etc/selinux/config
#source  /etc/selinux/config
#sudo systemctl stop firewalld
#sudo systemctl disable firewalld
groupadd zabbix
useradd zabbix -g zabbix -s /sbin/nologin
yum install epel-release -y
yum install pcre pcre-devel openssl openssl-devel gcc -y
tar -zxvf zabbix-3.2.6.tar.gz
cd /data/service/zabbix-3.2.6
./configure --prefix=/data/service/zabbix --enable-agent
make
make install
sed -i "s/Server=127.0.0.1/Server=10.0.0.40/" /data/service/zabbix/etc/zabbix_agentd.conf
sed -i "s/ServerActive=127.0.0.1/ServerActive=10.0.0.40/" /data/service/zabbix/etc/zabbix_agentd.conf
sed -i "s/# EnableRemoteCommands=0/EnableRemoteCommands=1/" /data/service/zabbix/etc/zabbix_agentd.conf
sed -i "s/# AllowRoot=0/AllowRoot=1/" /data/service/zabbix/etc/zabbix_agentd.conf
sed -i "s/# UnsafeUserParameters=0/UnsafeUserParameters=1/" /data/service/zabbix/etc/zabbix_agentd.conf
chmod 777 /data/service/zabbix/etc/zabbix_agentd.conf
echo "Include=/data/service/zabbix/etc/zabbix_agentd.conf.d/*.conf" >> /data/service/zabbix/etc/zabbix_agentd.conf
/data/service/zabbix/sbin/zabbix_agentd -c /data/service/zabbix/etc/zabbix_agentd.conf
chown zabbix.zabbix /tmp/zabbix_agentd.log
chown -R zabbix.zabbix /data/service/zabbix
