Skip to content

Commit

Permalink
Format files
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexRuiz7 committed Nov 26, 2024
1 parent 60839c3 commit 0129c1f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
9 changes: 6 additions & 3 deletions build-scripts/assemble.sh
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ function parse_args() {
# ====
function add_configuration_files() {
# Add our settings to the configuration files
cat "$PATH_CONF/security/roles.wazuh.yml" >> "$PATH_CONF/opensearch-security/roles.yml"
cat "$PATH_CONF/security/roles_mapping.wazuh.yml" >> "$PATH_CONF/opensearch-security/roles_mapping.yml"
cat "$PATH_CONF/security/roles.wazuh.yml" >>"$PATH_CONF/opensearch-security/roles.yml"
cat "$PATH_CONF/security/roles_mapping.wazuh.yml" >>"$PATH_CONF/opensearch-security/roles_mapping.yml"

cp "$PATH_CONF/opensearch.prod.yml" "$PATH_CONF/opensearch.yml"

rm -r "$PATH_CONF/security"
Expand Down Expand Up @@ -193,6 +193,9 @@ function add_wazuh_tools() {
curl -sL "${download_url}/wazuh-certs-tool.sh" -o "$PATH_PLUGINS"/opensearch-security/tools/wazuh-certs-tool.sh
}

# ====
# Add demo certificates installer
# ====
function add_demo_certs_installer() {
cp install-demo-certificates.sh "$PATH_PLUGINS"/opensearch-security/tools/
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ mkdir -p "$TMP_DIR"
# If demo certificates are explicitly solicited
# (ie. for dockerized cluster test environments)
# then, use hardcoded certs.
if [ ${USE_DEMO_CERTS:-false} = "true" ]
then
cat <<'ADMIN_KEY' > $TMP_DIR/admin-key.pem
if [ "${USE_DEMO_CERTS:-false}" = "true" ]; then
cat <<'ADMIN_KEY' >$TMP_DIR/admin-key.pem
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC3ebYoJC7NR6YU
aYDnhRlawrb6BD4Oj3VkLsk4hIEKLo0afcexZWhW2iKqK1d7KLQir7ZqmodyQpzR
Expand Down Expand Up @@ -49,7 +48,7 @@ V4hJcul3lbTnrbuRHvVEOGk=
-----END PRIVATE KEY-----
ADMIN_KEY

cat <<'ADMIN_CERT' > $TMP_DIR/admin.pem
cat <<'ADMIN_CERT' >$TMP_DIR/admin.pem
-----BEGIN CERTIFICATE-----
MIIDDjCCAfYCFD71oGZblxldV2/96zP2kZpIKOYgMA0GCSqGSIb3DQEBCwUAMDUx
DjAMBgNVBAsMBVdhenVoMQ4wDAYDVQQKDAVXYXp1aDETMBEGA1UEBwwKQ2FsaWZv
Expand All @@ -71,7 +70,7 @@ BzcZ+J6GzTHIZXHI77PvXHtf
-----END CERTIFICATE-----
ADMIN_CERT

cat <<'INDEXER_KEY' > $TMP_DIR/indexer-key.pem
cat <<'INDEXER_KEY' >$TMP_DIR/indexer-key.pem
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDJZsCQdRwFIszQ
XtccbLLs3aUquhbIdGwpDALXtOa8XWBRhusSLgftmNfIQg4adPVgqzXvij546wiQ
Expand Down Expand Up @@ -102,7 +101,7 @@ KhyfqIhMJFSEqFwz8nsLcDo=
-----END PRIVATE KEY-----
INDEXER_KEY

cat <<'INDEXER_CERT' > $TMP_DIR/indexer.pem
cat <<'INDEXER_CERT' >$TMP_DIR/indexer.pem
-----BEGIN CERTIFICATE-----
MIIDrTCCApWgAwIBAgIUXrjOPxnJtoICOqL+z9QzqccrhE0wDQYJKoZIhvcNAQEL
BQAwNTEOMAwGA1UECwwFV2F6dWgxDjAMBgNVBAoMBVdhenVoMRMwEQYDVQQHDApD
Expand All @@ -127,7 +126,7 @@ mVGWK9t6LlKwb/u1zTKn+Ayy24fzELpG/y5CF35BW+Zy
-----END CERTIFICATE-----
INDEXER_CERT

cat <<'ROOT_CA' > $TMP_DIR/root-ca.pem
cat <<'ROOT_CA' >$TMP_DIR/root-ca.pem
-----BEGIN CERTIFICATE-----
MIIDSzCCAjOgAwIBAgIUI7nMX6wJ4fcTo1JfSUNtuFNlgNIwDQYJKoZIhvcNAQEL
BQAwNTEOMAwGA1UECwwFV2F6dWgxDjAMBgNVBAoMBVdhenVoMRMwEQYDVQQHDApD
Expand Down Expand Up @@ -166,7 +165,7 @@ else
openssl genrsa -out "$TMP_DIR/indexer-key-temp.pem" 2048
openssl pkcs8 -inform PEM -outform PEM -in "$TMP_DIR/indexer-key-temp.pem" -topk8 -nocrypt -v1 PBE-SHA1-3DES -out "$TMP_DIR/indexer-key.pem"
openssl req -new -key "$TMP_DIR/indexer-key.pem" -subj "/C=US/L=California/O=Wazuh/OU=Wazuh/CN=node-0.wazuh.indexer" -out "$TMP_DIR/indexer.csr"
cat <<'INDEXER_EXT' > $TMP_DIR/indexer.ext
cat <<'INDEXER_EXT' >$TMP_DIR/indexer.ext
subjectAltName = @alt_names
[alt_names]
DNS.1 = localhost
Expand All @@ -191,4 +190,4 @@ chmod 400 "$CERTS_DIR"/*
chown -R wazuh-indexer:wazuh-indexer "$CERTS_DIR"

# Cleanup /tmp directory
rm -r "$TMP_DIR"
rm -r "$TMP_DIR"
16 changes: 7 additions & 9 deletions distribution/packages/src/deb/debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ chown -R wazuh-indexer:wazuh-indexer ${data_dir}
chown -R wazuh-indexer:wazuh-indexer ${pid_dir}
chown -R wazuh-indexer:wazuh-indexer ${tmp_dir}


export OPENSEARCH_PATH_CONF=${OPENSEARCH_PATH_CONF:-${config_dir}}
# Apply Performance Analyzer settings, as per https://github.com/opensearch-project/opensearch-build/blob/2.18.0/scripts/pkg/build_templates/current/opensearch/deb/debian/postinst#L28-L37
if ! grep -q '## OpenSearch Performance Analyzer' "$OPENSEARCH_PATH_CONF/jvm.options"; then
Expand All @@ -44,36 +43,35 @@ if ! grep -q '## OpenSearch Performance Analyzer' "$OPENSEARCH_PATH_CONF/jvm.opt
echo "-Djdk.attach.allowAttachSelf=true"
echo "-Djava.security.policy=file://$OPENSEARCH_PATH_CONF/opensearch-performance-analyzer/opensearch_security.policy"
echo "--add-opens=jdk.attach/sun.tools.attach=ALL-UNNAMED"
} >> "$OPENSEARCH_PATH_CONF/jvm.options"
} >>"$OPENSEARCH_PATH_CONF/jvm.options"
fi

# Reload systemctl daemon
if command -v systemctl > /dev/null; then
if command -v systemctl >/dev/null; then
systemctl daemon-reload
fi

# Reload other configs
if command -v systemctl > /dev/null; then
if command -v systemctl >/dev/null; then
systemctl restart systemd-sysctl.service || true
fi

if command -v systemd-tmpfiles > /dev/null; then
if command -v systemd-tmpfiles >/dev/null; then
systemd-tmpfiles --create wazuh-indexer.conf
fi


if ! [ -d "${config_dir}/certs" ] && [ -f "${product_dir}/plugins/opensearch-security/tools/install-demo-certificates.sh" ]; then
echo "No certificates detected in ${config_dir}, installing demo certificates..."
echo "### If you are using a custom certificates path, ignore this message."
export USE_DEMO_CERTS
bash "${product_dir}/plugins/opensearch-security/tools/install-demo-certificates.sh" > "${log_dir}/install_demo_certificates.log" 2>&1
bash "${product_dir}/plugins/opensearch-security/tools/install-demo-certificates.sh" >"${log_dir}/install_demo_certificates.log" 2>&1
fi

if [ -f $restart_service ]; then
rm -f $restart_service
echo "Restarting wazuh-indexer service..."
if command -v systemctl > /dev/null; then
systemctl restart wazuh-indexer.service > /dev/null 2>&1
if command -v systemctl >/dev/null; then
systemctl restart wazuh-indexer.service >/dev/null 2>&1
fi
exit 0
fi
Expand Down

0 comments on commit 0129c1f

Please sign in to comment.