From 0129c1f54a0ce61cd5bd348c5c988c0f4184b60c Mon Sep 17 00:00:00 2001 From: Alex Ruiz Date: Tue, 26 Nov 2024 12:15:16 +0100 Subject: [PATCH] Format files --- build-scripts/assemble.sh | 9 ++++++--- .../common/scripts/install-demo-certificates.sh | 17 ++++++++--------- distribution/packages/src/deb/debian/postinst | 16 +++++++--------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/build-scripts/assemble.sh b/build-scripts/assemble.sh index f4531ca7f0505..6d0d8fcb40857 100644 --- a/build-scripts/assemble.sh +++ b/build-scripts/assemble.sh @@ -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" @@ -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/ } diff --git a/distribution/packages/src/common/scripts/install-demo-certificates.sh b/distribution/packages/src/common/scripts/install-demo-certificates.sh index e3ad5fd82f46c..93770e3979e74 100644 --- a/distribution/packages/src/common/scripts/install-demo-certificates.sh +++ b/distribution/packages/src/common/scripts/install-demo-certificates.sh @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -191,4 +190,4 @@ chmod 400 "$CERTS_DIR"/* chown -R wazuh-indexer:wazuh-indexer "$CERTS_DIR" # Cleanup /tmp directory -rm -r "$TMP_DIR" \ No newline at end of file +rm -r "$TMP_DIR" diff --git a/distribution/packages/src/deb/debian/postinst b/distribution/packages/src/deb/debian/postinst index c2e309294fcd9..d5a1e5e8a46eb 100644 --- a/distribution/packages/src/deb/debian/postinst +++ b/distribution/packages/src/deb/debian/postinst @@ -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 @@ -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