updated already configured check and updated hostname command

This commit is contained in:
2021-01-05 12:14:14 -05:00
parent 3b31a7bf5c
commit 19046926f1

View File

@@ -85,12 +85,16 @@ fi
cheeck before running this as it adds lines to keep comments
if [ $(grep -c Hostname=Zabbix /etc/zabbix/zabbix_agentd.conf) -eq 1 ]; then
if [ $(grep -c Server=127.0.0.1 /etc/zabbix/zabbix_agentd.conf) -eq 1 ]; then
# ask for the hostname
read -e -p "Enter Hostname: " -i "$(cat /etc/hostname)" hostname
# configure the hostname
sed --in-place 's/^Hostname=Zabbix\ server/Hostname='${hostname}'/' /etc/zabbix/zabbix_agentd.conf
# configure the hostname, check for older config and newer config
if [ $(grep -c Hostname=Zabbix /etc/zabbix/zabbix_agentd.conf) -eq 1 ]; then
sed --in-place 's/^Hostname=Zabbix\ server/Hostname='${hostname}'/' /etc/zabbix/zabbix_agentd.conf
else
sed --in-place $'s/^# Hostname=/# Hostname=\\\nHostname='${hostname}'/' /etc/zabbix/zabbix_agentd.conf
fi
# 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