diff --git a/wazuh-odfe/config/etc/cont-init.d/0-wazuh-init b/wazuh-odfe/config/etc/cont-init.d/0-wazuh-init index b45dced5..e3c9ebfa 100644 --- a/wazuh-odfe/config/etc/cont-init.d/0-wazuh-init +++ b/wazuh-odfe/config/etc/cont-init.d/0-wazuh-init @@ -74,6 +74,23 @@ apply_exclusion_data() { done } +############################################################################## +# This function will rename in the permanent data volume every file +# contained in PERMANENT_DATA_MOVE +############################################################################## + +move_data_files() { + for mov_file in "${PERMANENT_DATA_MOVE[@]}"; do + file_split=( $mov_file ) + if [ -e ${file_split[0]} ] + then + print "moving ${mov_file}" + exec_cmd "mv -f ${mov_file}" + fi + done +} + + ############################################################################## # This function will delete from the permanent data volume every file # contained in PERMANENT_DATA_DEL @@ -84,7 +101,7 @@ remove_data_files() { if [ -e ${del_file} ] then print "Removing ${del_file}" - exec_cmd "rm ${del_file}" + exec_cmd "rm -f ${del_file}" fi done } @@ -158,6 +175,9 @@ main() { # Restore files stored in permanent data that are not permanent (i.e. internal_options.conf) apply_exclusion_data + # Rename files stored in permanent data (i.e. queue/ossec) + move_data_files + # Remove some files in permanent_data (i.e. .template.db) remove_data_files diff --git a/wazuh-odfe/config/permanent_data.env b/wazuh-odfe/config/permanent_data.env index 47f5c06b..9ec743af 100644 --- a/wazuh-odfe/config/permanent_data.env +++ b/wazuh-odfe/config/permanent_data.env @@ -4,6 +4,7 @@ PERMANENT_DATA[((i++))]="/var/ossec/api/configuration" PERMANENT_DATA[((i++))]="/var/ossec/etc" PERMANENT_DATA[((i++))]="/var/ossec/logs" PERMANENT_DATA[((i++))]="/var/ossec/queue" +PERMANENT_DATA[((i++))]="/var/ossec/queue/logcollector" PERMANENT_DATA[((i++))]="/var/ossec/agentless" PERMANENT_DATA[((i++))]="/var/ossec/var/multigroups" PERMANENT_DATA[((i++))]="/var/ossec/integrations" @@ -63,3 +64,8 @@ export PERMANENT_DATA_EXCP i=0 PERMANENT_DATA_DEL[((i++))]="/var/ossec/queue/db/.template.db" export PERMANENT_DATA_DEL + +i=0 +PERMANENT_DATA_MOVE[((i++))]="/var/ossec/logs/ossec /var/ossec/logs/wazuh" +PERMANENT_DATA_MOVE[((i++))]="/var/ossec/queue/ossec /var/ossec/queue/sockets" +export PERMANENT_DATA_MOVE \ No newline at end of file