diff --git a/zabbix_agent.sh b/zabbix_agent.sh index db140ba..d554186 100644 --- a/zabbix_agent.sh +++ b/zabbix_agent.sh @@ -85,12 +85,12 @@ fi #cheeck before running this as it adds lines to keep comments -if [ $(grep -c Server=127.0.0.1 /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, check for older config and newer config - if [ $(grep -c Hostname=Zabbix /etc/zabbix/zabbix_agentd.conf) -eq 1 ]; then + 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