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

Improvements in Wazuh dahboard 4.6.0-2.8.0 package #2423

Merged
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions stack/dashboard/base/builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ cp ./etc/styles.js ./src/core/server/rendering/views/styles.js
sed -i "s|defaultValue: ''|defaultValue: \'Wazuh\'|g" ./src/core/server/opensearch_dashboards_config.js
sed -i "90s|defaultValue: true|defaultValue: false|g" ./src/core/server/opensearch_dashboards_config.js
# Replace config path
sed -i "s'\$DIR/config'/etc/wazuh-dashboard'g" ./bin/opensearch-dashboards
sed -i "s'\$DIR/config'/etc/wazuh-dashboard'g" ./bin/opensearch-dashboards-keystore
sed -i "s'\$DIR/config'/etc/wazuh-dashboard'g" ./bin/opensearch-dashboards-plugin
sed -i "s'NODE_OPTIONS=\"--no-warnings --max-http-header-size=65536 \$OSD_NODE_OPTS \$NODE_OPTIONS\" NODE_ENV=production exec \"\${NODE}\" \"\${DIR}/src/cli/dist\" \${@}'NODE_OPTIONS=\"--no-warnings --max-http-header-size=65536 \$OSD_NODE_OPTS \$NODE_OPTIONS\"'g" ./bin/opensearch-dashboards
echo "NODE_ENV=production exec \"\${NODE}\" \${NODE_OPTIONS} \"\${DIR}/src/cli/dist\" \${@}" >> ./bin/opensearch-dashboards
# Add fix to Node variables as Node is not using the NODE_OPTIONS environment variables
sed -i 's/NODE_OPTIONS="$OSD_NODE_OPTS_PREFIX $OSD_NODE_OPTS $NODE_OPTIONS"/NODE_OPTIONS="$OSD_NODE_OPTS_PREFIX $OSD_NODE_OPTS $NODE_OPTIONS"\n/g' ./bin/use_node
sed -i 's/exec "${NODE}"/NODE_ENV=production exec "${NODE}" ${NODE_OPTIONS} /g' ./bin/use_node
# Replace the redirection to `home` in the header logo
sed -i "s'/app/home'/app/wazuh'g" ./src/core/target/public/core.entry.js
# Replace others redirections to `home`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ User=wazuh-dashboard
Group=wazuh-dashboard
EnvironmentFile=-/etc/default/wazuh-dashboard
EnvironmentFile=-/etc/sysconfig/wazuh-dashboard
ExecStart=/usr/share/wazuh-dashboard/bin/opensearch-dashboards
ExecStart=/usr/share/wazuh-dashboard/bin/opensearch-dashboards -c /etc/wazuh-dashboard/opensearch_dashboards.yml
WorkingDirectory=/usr/share/wazuh-dashboard

[Install]
Expand Down
6 changes: 5 additions & 1 deletion stack/dashboard/deb/debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ case "$1" in
service wazuh-dashboard restart > /dev/null 2>&1
fi
fi
if [ ! -f "${INSTALLATION_DIR}"/config/opensearch_dashboards.keystore ]; then
# Move keystore file if upgrade (file exists in install dir in <= 4.6.0)
if [ -f "${INSTALLATION_DIR}"/config/opensearch_dashboards.keystore ]; then
mv "${INSTALLATION_DIR}"/config/opensearch_dashboards.keystore "${CONFIG_DIR}"/opensearch_dashboards.keystore
elif [ ! -f "${CONFIG_DIR}"/opensearch_dashboards.keystore ]; then
runuser "${NAME}" --shell="/bin/bash" --command="${INSTALLATION_DIR}/bin/opensearch-dashboards-keystore create" > /dev/null 2>&1
runuser "${NAME}" --shell="/bin/bash" --command="echo kibanaserver | ${INSTALLATION_DIR}/bin/opensearch-dashboards-keystore add opensearch.username --stdin" > /dev/null 2>&1
runuser "${NAME}" --shell="/bin/bash" --command="echo kibanaserver | ${INSTALLATION_DIR}/bin/opensearch-dashboards-keystore add opensearch.password --stdin" > /dev/null 2>&1
chmod 640 "${CONFIG_DIR}"/opensearch_dashboards.keystore
fi
;;

Expand Down
5 changes: 3 additions & 2 deletions stack/dashboard/deb/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ override_dh_install:
useradd -g $(GROUP) $(USER)

tar -xf $(DASHBOARD_FILE)
sed -i "s/cross_platform_1.REPO_ROOT\, 'config\//'\/etc\/wazuh-dashboard\/', '/g" "wazuh-dashboard-base/node_modules/@osd/utils/target/path/index.js"
sed -i 's/OSD_NODE_OPTS_PREFIX/OSD_PATH_CONF="\/etc\/wazuh-dashboard" OSD_NODE_OPTS_PREFIX/g' "wazuh-dashboard-base/bin/opensearch-dashboards"
sed -i 's/OSD_USE_NODE_JS_FILE_PATH/OSD_PATH_CONF="\/etc\/wazuh-dashboard" OSD_USE_NODE_JS_FILE_PATH/g' "wazuh-dashboard-base/bin/opensearch-dashboards-keystore"

mkdir -p $(TARGET_DIR)$(CONFIG_DIR)
mkdir -p $(TARGET_DIR)$(INSTALLATION_DIR)
Expand Down Expand Up @@ -105,7 +106,7 @@ override_dh_fixperms:
chmod 750 $(TARGET_DIR)/etc/default/wazuh-dashboard
chmod 640 "$(TARGET_DIR)$(CONFIG_DIR)"/opensearch_dashboards.yml
chmod 640 "$(TARGET_DIR)$(CONFIG_DIR)"/node.options
chmod 640 $(TARGET_DIR)/etc/systemd/system/wazuh-dashboard.service
chmod 640 "$(TARGET_DIR)"/etc/systemd/system/wazuh-dashboard.service
find "$(TARGET_DIR)$(INSTALLATION_DIR)" -type d -exec chmod 750 {} \;
find "$(TARGET_DIR)$(INSTALLATION_DIR)" -type f -perm 644 -exec chmod 640 {} \;
find "$(TARGET_DIR)$(INSTALLATION_DIR)" -type f -perm 755 -exec chmod 750 {} \;
Expand Down
21 changes: 14 additions & 7 deletions stack/dashboard/rpm/wazuh-dashboard.spec
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ useradd -g %{GROUP} %{USER}
%build

tar -xf %{DASHBOARD_FILE}
sed -i "s/cross_platform_1.REPO_ROOT\, 'config\//'\/etc\/wazuh-dashboard\/', '/g" "wazuh-dashboard-base/node_modules/@osd/utils/target/path/index.js"

# Set custom config dir
sed -i 's/OSD_NODE_OPTS_PREFIX/OSD_PATH_CONF="\/etc\/wazuh-dashboard" OSD_NODE_OPTS_PREFIX/g' "wazuh-dashboard-base/bin/opensearch-dashboards"
sed -i 's/OSD_USE_NODE_JS_FILE_PATH/OSD_PATH_CONF="\/etc\/wazuh-dashboard" OSD_USE_NODE_JS_FILE_PATH/g' "wazuh-dashboard-base/bin/opensearch-dashboards-keystore"

# -----------------------------------------------------------------------------

Expand Down Expand Up @@ -133,12 +136,6 @@ fi
%post
setcap 'cap_net_bind_service=+ep' %{INSTALL_DIR}/node/bin/node

if [ ! -f %{INSTALLATION_DIR}/config/opensearch_dashboards.keystore ]; then
runuser %{USER} --shell="/bin/bash" --command="%{INSTALL_DIR}/bin/opensearch-dashboards-keystore create" > /dev/null 2>&1
runuser %{USER} --shell="/bin/bash" --command="echo kibanaserver | %{INSTALL_DIR}/bin/opensearch-dashboards-keystore add opensearch.username --stdin" > /dev/null 2>&1
runuser %{USER} --shell="/bin/bash" --command="echo kibanaserver | %{INSTALL_DIR}/bin/opensearch-dashboards-keystore add opensearch.password --stdin" > /dev/null 2>&1
fi

# -----------------------------------------------------------------------------

%preun
Expand Down Expand Up @@ -184,6 +181,16 @@ if [ ! -d %{PID_DIR} ]; then
chown %{USER}:%{GROUP} %{PID_DIR}
fi

# Move keystore file if upgrade (file exists in install dir in <= 4.6.0)
if [ -f "%{INSTALL_DIR}"/config/opensearch_dashboards.keystore ]; then
mv "%{INSTALL_DIR}"/config/opensearch_dashboards.keystore "%{CONFIG_DIR}"/opensearch_dashboards.keystore
elif [ ! -f %{CONFIG_DIR}/opensearch_dashboards.keystore ]; then
runuser %{USER} --shell="/bin/bash" --command="%{INSTALL_DIR}/bin/opensearch-dashboards-keystore create" > /dev/null 2>&1
runuser %{USER} --shell="/bin/bash" --command="echo kibanaserver | %{INSTALL_DIR}/bin/opensearch-dashboards-keystore add opensearch.username --stdin" > /dev/null 2>&1
runuser %{USER} --shell="/bin/bash" --command="echo kibanaserver | %{INSTALL_DIR}/bin/opensearch-dashboards-keystore add opensearch.password --stdin" > /dev/null 2>&1
chmod 640 "%{CONFIG_DIR}"/opensearch_dashboards.keystore
fi

if [ -f %{INSTALL_DIR}/wazuh-dashboard.restart ]; then
rm -f %{INSTALL_DIR}/wazuh-dashboard.restart
if command -v systemctl > /dev/null 2>&1 && systemctl > /dev/null 2>&1; then
Expand Down
Loading