From 974c359b5480b4fc19e1dfba97f944d7e1d75c0d Mon Sep 17 00:00:00 2001 From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com> Date: Fri, 2 Oct 2020 17:59:40 +0200 Subject: [PATCH 1/2] Implement PR #261 --- .../config/etc/cont-init.d/0-wazuh-init | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/wazuh-opendistro/config/etc/cont-init.d/0-wazuh-init b/wazuh-opendistro/config/etc/cont-init.d/0-wazuh-init index 1aa78f65..af248c6c 100644 --- a/wazuh-opendistro/config/etc/cont-init.d/0-wazuh-init +++ b/wazuh-opendistro/config/etc/cont-init.d/0-wazuh-init @@ -126,6 +126,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' ${WAZUH_INSTALL_PATH}/etc/ossec.conf + ############################################################################## # Main function @@ -154,7 +165,7 @@ main() { mount_files # Trap exit signals and do a proper shutdown - trap "ossec_shutdown; exit" SIGINT SIGTERM + trap "ossec_shutdown; exit" SIGINT SIGTERM # Delete temporary data folder rm -rf ${WAZUH_INSTALL_PATH}/data_tmp From bed34c33ca6f8fa66b72a373ccdc1d9e37f97b2b Mon Sep 17 00:00:00 2001 From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com> Date: Fri, 2 Oct 2020 18:03:54 +0200 Subject: [PATCH 2/2] Remove legacy code During this s6 start sequence the Wazuh processes are not started yet --- wazuh-opendistro/config/etc/cont-init.d/0-wazuh-init | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/wazuh-opendistro/config/etc/cont-init.d/0-wazuh-init b/wazuh-opendistro/config/etc/cont-init.d/0-wazuh-init index af248c6c..12460969 100644 --- a/wazuh-opendistro/config/etc/cont-init.d/0-wazuh-init +++ b/wazuh-opendistro/config/etc/cont-init.d/0-wazuh-init @@ -118,14 +118,6 @@ mount_files() { fi } -############################################################################## -# Stop OSSEC -############################################################################## - -function ossec_shutdown(){ - ${WAZUH_INSTALL_PATH}/bin/ossec-control stop; -} - ############################################################################## # Allow users to set the container hostname as dynamically on # container start. @@ -164,9 +156,6 @@ main() { # Mount selected files (WAZUH_CONFIG_MOUNT) to container mount_files - # Trap exit signals and do a proper shutdown - trap "ossec_shutdown; exit" SIGINT SIGTERM - # Delete temporary data folder rm -rf ${WAZUH_INSTALL_PATH}/data_tmp