[v4,5/6] zabbix_agentd: By default only listen on GREEN ip

Message ID 20220303210254.3116-6-robin.roevens@disroot.org
State Superseded
Headers
Series zabbix_agentd: Update to v5.0.21 (LTS) |

Commit Message

Robin Roevens March 3, 2022, 9:02 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 |  3 +++
 src/paks/zabbix_agentd/install.sh       | 10 ++++++++++
 2 files changed, 13 insertions(+)
  

Patch

diff --git a/config/zabbix_agentd/zabbix_agentd.conf b/config/zabbix_agentd/zabbix_agentd.conf
index 76cd87528..a12fe3a60 100644
--- a/config/zabbix_agentd/zabbix_agentd.conf
+++ b/config/zabbix_agentd/zabbix_agentd.conf
@@ -13,6 +13,9 @@ 
 Server=127.0.0.1
 ServerActive=127.0.0.1
 
+# List of comma delimited IP addresses that the agent should listen on.
+ListenIP=GREEN_ADDRESS
+
 # This line activates IPFire specific userparameters. See IPFire wiki for details.
 # To deactivate them: Comment this line out.
 # (DO NOT REMOVE OR ALTER IT as then it will be re-added on next upgrade)
diff --git a/src/paks/zabbix_agentd/install.sh b/src/paks/zabbix_agentd/install.sh
index d9130dfb4..a64d4c84f 100644
--- a/src/paks/zabbix_agentd/install.sh
+++ b/src/paks/zabbix_agentd/install.sh
@@ -76,4 +76,14 @@  if [ $? -eq 1 ]; then
 	echo "Include=/var/ipfire/zabbix_agentd/zabbix_agentd_ipfire_mandatory.conf" >> /etc/zabbix_agentd/zabbix_agentd.conf
 fi
 
+# 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
+	else
+		sed -i -e "\|ListenIP=GREEN_ADDRESS|d" /etc/zabbix_agentd/zabbix_agentd.conf
+	fi
+) || :
+
 start_service --background ${NAME}