Update 'zabbix_agent.sh'
This commit is contained in:
@@ -46,12 +46,29 @@ fi
|
|||||||
# ask for the hostname
|
# ask for the hostname
|
||||||
read -e -p "Enter Hostname: " -i "$(cat /etc/hostname)" 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 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}"
|
||||||
Reference in New Issue
Block a user