updated to use regex for grep
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user