updated already configured check and updated hostname command
This commit is contained in:
@@ -85,12 +85,16 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
cheeck before running this as it adds lines to keep comments
|
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
|
# ask for the hostname
|
||||||
read -e -p "Enter Hostname: " -i "$(cat /etc/hostname)" hostname
|
read -e -p "Enter Hostname: " -i "$(cat /etc/hostname)" hostname
|
||||||
|
|
||||||
# configure the hostname
|
# configure the hostname, check for older config and newer config
|
||||||
sed --in-place 's/^Hostname=Zabbix\ server/Hostname='${hostname}'/' /etc/zabbix/zabbix_agentd.conf
|
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
|
# configure the zabbix server
|
||||||
sed --in-place 's/^Server=127.0.0.1/Server='${ZABBIX_SERVER}'/' /etc/zabbix/zabbix_agentd.conf
|
sed --in-place 's/^Server=127.0.0.1/Server='${ZABBIX_SERVER}'/' /etc/zabbix/zabbix_agentd.conf
|
||||||
# configure the zabbix server
|
# configure the zabbix server
|
||||||
|
|||||||
Reference in New Issue
Block a user