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

refactor (wazuh_app_config): improvement of file existence check. #1320

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 17 additions & 19 deletions build-docker-images/wazuh-dashboard/config/wazuh_app_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,26 @@ declare -A CONFIG_MAP=(
[wazuh.monitoring.replicas]=$WAZUH_MONITORING_REPLICAS
)

if [[ -f "$dashboard_config_file" ]]
then
echo "Wazuh APP already configured";
else
_config_parameters=(
"hosts:"
" - 1513629884013:"
" url: $wazuh_url"
" port: $wazuh_port"
" username: $api_username"
" password: $api_password"
" run_as: $api_run_as"
);
printf '%s\n' "${_config_parameters[@]}" > "$dashboard_config_file";
fi;


for i in "${!CONFIG_MAP[@]}"
do
if [ "${CONFIG_MAP[$i]}" != "" ]; then
sed -i 's/.*#'"$i"'.*/'"$i"': '"${CONFIG_MAP[$i]}"'/' $dashboard_config_file
fi
done


grep -q 1513629884013 $dashboard_config_file
_config_exists=$?

if [[ $_config_exists -ne 0 ]]; then
cat << EOF >> $dashboard_config_file
hosts:
- 1513629884013:
url: $wazuh_url
port: $wazuh_port
username: $api_username
password: $api_password
run_as: $api_run_as
EOF
else
echo "Wazuh APP already configured"
fi