Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update RPM spec file to avoid overwriting modified config files #410

Merged
merged 8 commits into from
Sep 19, 2024
7 changes: 7 additions & 0 deletions distribution/packages/src/deb/debian/postinst
AlexRuiz7 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ tmp_dir=/var/log/wazuh-indexer/tmp
# Create needed directories
mkdir -p ${tmp_dir}

# Create config files only if not already present
cp -n /etc/init.d/wazuh-indexer.new /etc/init.d/wazuh-indexer
cp -n ${config_dir}/jvm.options.new ${config_dir}/jvm.options
cp -n ${config_dir}/opensearch.yml.new ${config_dir}/opensearch.yml
cp -n ${config_dir}/opensearch-security/roles.yml.new ${config_dir}/opensearch-security/roles.yml
cp -n ${config_dir}/opensearch-security/internal_users.yml.new ${config_dir}/opensearch-security/internal_users.yml

# Set owner
chown -R wazuh-indexer:wazuh-indexer ${product_dir}
chown -R wazuh-indexer:wazuh-indexer ${config_dir}
Expand Down
13 changes: 13 additions & 0 deletions distribution/packages/src/deb/debmake_install.sh
AlexRuiz7 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,18 @@ for i in "${binary_files[@]}"; do
chmod -c 750 "$i"
done

# Append ".new" to configuration file names
dot_new_config_files=(
"${buildroot}/etc/init.d/${name}"
"${buildroot}/${config_dir}/jvm.options"
"${buildroot}/${config_dir}/opensearch.yml"
"${buildroot}/${config_dir}/opensearch-security/roles.yml"
"${buildroot}/${config_dir}/opensearch-security/internal_users.yml"
)

for i in "${dot_new_config_files[@]}"
do
mv "$i" "$i.new"
done

exit 0
1 change: 1 addition & 0 deletions distribution/packages/src/rpm/wazuh-indexer.rpm.spec
AlexRuiz7 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ exit 0
%config(noreplace) %attr(660, %{name}, %{name}) %{config_dir}/log4j2.properties
%config(noreplace) %attr(660, %{name}, %{name}) %{config_dir}/jvm.options
%config(noreplace) %attr(660, %{name}, %{name}) %{config_dir}/opensearch.yml
%config(noreplace) %attr(640, %{name}, %{name}) %{config_dir}/opensearch-security/*


%if %observability_plugin
Expand Down