[v3,4/5] zabbix_agentd: By default only listen on GREEN ip

Message ID 20220209232631.14673-5-robin.roevens@disroot.org
State Superseded
Headers
Series zabbix_agentd: Update to v5.0.20 (LTS) and more |

Commit Message

Robin Roevens Feb. 9, 2022, 11:26 p.m. UTC
  - Change zabbix_agentd.conf during install to only listen on the
  GREEN ip by default.

Signed-off-by: Robin Roevens <robin.roevens@disroot.org>
---
 config/zabbix_agentd/zabbix_agentd.conf |  2 ++
 src/paks/zabbix_agentd/install.sh       | 10 ++++++++++
 2 files changed, 12 insertions(+)
  

Patch

diff --git a/config/zabbix_agentd/zabbix_agentd.conf b/config/zabbix_agentd/zabbix_agentd.conf
index aa8b899dc..5eea7d4b5 100644
--- a/config/zabbix_agentd/zabbix_agentd.conf
+++ b/config/zabbix_agentd/zabbix_agentd.conf
@@ -132,6 +132,8 @@  Server=127.0.0.1
 # Default:
 # ListenIP=0.0.0.0
 
+ListenIP=GREEN_ADDRESS
+
 ### Option: StartAgents
 #	Number of pre-forked instances of zabbix_agentd that process passive checks.
 #	If set to 0, disables passive checks and the agent will not listen on any TCP port.
diff --git a/src/paks/zabbix_agentd/install.sh b/src/paks/zabbix_agentd/install.sh
index 4ef4b5be6..f7218a603 100644
--- a/src/paks/zabbix_agentd/install.sh
+++ b/src/paks/zabbix_agentd/install.sh
@@ -62,6 +62,16 @@  ln -sf ../init.d/zabbix_agentd /etc/rc.d/rc6.d/K02zabbix_agentd
 
 restore_backup ${NAME}
 
+# By default, only listen on GREEN
+( 
+	eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
+	if [ -n "${GREEN_ADDRESS}" ]; then
+		sed -i -e "s|ListenIP=GREEN_ADDRESS|ListenIP=${GREEN_ADDRESS}|g" /etc/zabbix_agentd/zabbix_agentd.conf.ipfirenew
+	else
+		sed -i -e "\|ListenIP=GREEN_ADDRESS|d" /etc/zabbix_agentd/zabbix_agentd.conf.ipfirenew
+	fi
+) || :
+
 # Put zabbix configfiles in place
 setup_configfile /etc/zabbix_agentd/zabbix_agentd.conf
 setup_configfile /etc/sudoers.d/zabbix