From 8cdfca24cfd154e69ddee7eb3a3867b282d2750b Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lachance Date: Thu, 3 Oct 2019 10:00:37 -0400 Subject: [PATCH 1/2] + Add a simple sed in the Wazuh manager configuration script to replace "to_be_replaced_by_hostname" by the hostname in ossec.conf --- wazuh/config/00-wazuh.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/wazuh/config/00-wazuh.sh b/wazuh/config/00-wazuh.sh index 32fdd4f4..75573829 100644 --- a/wazuh/config/00-wazuh.sh +++ b/wazuh/config/00-wazuh.sh @@ -104,6 +104,17 @@ function ossec_shutdown(){ ${WAZUH_INSTALL_PATH}/bin/ossec-control stop; } +############################################################################## +# Allow users to set the container hostname as dynamically on +# container start. +# +# To use this: +# 1. Create your own ossec.conf file +# 2. In your ossec.conf file, set to_be_replaced_by_hostname as your node_name +# 3. Mount your custom ossec.conf file at $WAZUH_CONFIG_MOUNT/etc/ossec.conf +############################################################################## +sed -i 's/to_be_replaced_by_hostname<\/node_name>/'"${HOSTNAME}"'<\/node_name>/g' /var/ossec/etc/ossec.conf + # Trap exit signals and do a proper shutdown trap "ossec_shutdown; exit" SIGINT SIGTERM From 237f55d7e2aff41f2eafe070a0a0be9e684fb043 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lachance Date: Mon, 7 Oct 2019 11:03:40 -0400 Subject: [PATCH 2/2] * Apply Jose's code review --- wazuh/config/00-wazuh.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wazuh/config/00-wazuh.sh b/wazuh/config/00-wazuh.sh index 75573829..9d5614f9 100644 --- a/wazuh/config/00-wazuh.sh +++ b/wazuh/config/00-wazuh.sh @@ -113,7 +113,7 @@ function ossec_shutdown(){ # 2. In your ossec.conf file, set to_be_replaced_by_hostname as your node_name # 3. Mount your custom ossec.conf file at $WAZUH_CONFIG_MOUNT/etc/ossec.conf ############################################################################## -sed -i 's/to_be_replaced_by_hostname<\/node_name>/'"${HOSTNAME}"'<\/node_name>/g' /var/ossec/etc/ossec.conf +sed -i 's/to_be_replaced_by_hostname<\/node_name>/'"${HOSTNAME}"'<\/node_name>/g' ${WAZUH_INSTALL_PATH}/etc/ossec.conf # Trap exit signals and do a proper shutdown trap "ossec_shutdown; exit" SIGINT SIGTERM