Update 'zabbix_agent.sh'

This commit is contained in:
2019-08-20 18:23:58 -04:00
parent ee6cbb6741
commit 09915b4969

View File

@@ -46,12 +46,29 @@ fi
# ask for the hostname
read -e -p "Enter Hostname: " -i "$(cat /etc/hostname)" hostname
sed --in-place "s/^Hostname=Zabbix\ server/Hostname=${hostname}/" /etc/zabbix/zabbix_agentd.conf
# configure the hostname
sed --in-place 's/^Hostname=Zabbix\ server/Hostname='${hostname}'/' /etc/zabbix/zabbix_agentd.conf
# configure the zabbix server
sed --in-place 's/^Server=127.0.0.1/Server='${ZABBIX_SERVER}'/' /etc/zabbix/zabbix_agentd.conf
# configure the zabbix server
sed --in-place 's/^ServerActive=127.0.0.1/ServerActive='${ZABBIX_SERVER}'/' /etc/zabbix/zabbix_agentd.conf
# configure the encryption
sed --in-place $'s/^# TLSAccept=unencrypted/# TLSAccept=unencrypted\\\n&TLSAccept=psk/' /etc/zabbix/zabbix_agentd.conf
sed --in-place $'s/^# TLSConnect=unencrypted/# TLSConnect=unencrypted\\\n&TLSConnect=psk/' /etc/zabbix/zabbix_agentd.conf
PSKID=$(openssl rand -hex 8)
sed --in-place $'s/^# TLSPSKIdentity=/# TLSPSKIdentity=\\\n&# TLSPSKIdentity='${PSKID}'/' /etc/zabbix/zabbix_agentd.conf
# generate psk
TLSPSK=$(openssl rand -hex 32 | tee /etc/zabbix/zabbix_agentd.psk)
sed --in-place $'s/^# TLSPSKFile=/# TLSPSKFile=\\\nTLSPSKFile=\/etc\/zabbix\/zabbix_agentd.psk/' /etc/zabbix/zabbix_agentd.conf
sed --in-place "s/^Server=127.0.0.1/Server=${ZABBIX_SERVER}/" /etc/zabbix/zabbix_agentd.conf
sed --in-place "s/^ServerActive=127.0.0.1/ServerActive=${ZABBIX_SERVER}/" /etc/zabbix/zabbix_agentd.conf
systemctl restart zabbix-agent
systemctl enable zabbix-agent
systemctl enable zabbix-agent
echo "############################################################"
echo "## Encryption Details ##"
echo "## Please enter the PSK ID and PSK into the Zabbix Server ##"
echo "############################################################"
echo "PSK Identity = ${PSKID}"
echo "PSK = ${TLSPSK}"