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

Add wazuh-template.json to packages #116

Merged
merged 10 commits into from
Jan 19, 2024
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,7 @@ testfixtures_shared/
.ci/jobs/

# build files generated
doc-tools/missing-doclet/bin/
doc-tools/missing-doclet/bin/

# Wazuh template (currently downloaded from the wazuh/wazuh repo directly)
distribution/src/config/wazuh-template.json
3 changes: 2 additions & 1 deletion distribution/packages/src/deb/debmake_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fi

curdir=$1
product_dir=/usr/share/wazuh-indexer
# config_dir=/etc/wazuh-indexer
config_dir=/etc/wazuh-indexer
data_dir=/var/lib/wazuh-indexer
log_dir=/var/log/wazuh-indexer
pid_dir=/run/wazuh-indexer
Expand All @@ -35,6 +35,7 @@ chmod -c 0755 "${buildroot}${product_dir}"/bin/*
if [ -d "${buildroot}${product_dir}"/plugins/opensearch-security ]; then
chmod -c 0755 "${buildroot}${product_dir}"/plugins/opensearch-security/tools/*
fi
chmod -c 660 "${buildroot}${config_dir}"/wazuh-template.json

# Change Permissions
chmod -Rf a+rX,u+w,g-w,o-w "${buildroot}"/*
AlexRuiz7 marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
9 changes: 4 additions & 5 deletions distribution/packages/src/rpm/wazuh-indexer.rpm.spec
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ mkdir -p %{buildroot}%{pid_dir}
mkdir -p %{buildroot}%{product_dir}/plugins
# Install directories/files
cp -a etc usr var %{buildroot}
chmod 0755 %{buildroot}%{product_dir}/bin/*
chmod 0750 %{buildroot}%{product_dir}/bin/*
if [ -d %{buildroot}%{product_dir}/plugins/opensearch-security ]; then
chmod 0755 %{buildroot}%{product_dir}/plugins/opensearch-security/tools/*
chmod 0640 %{buildroot}%{product_dir}/plugins/opensearch-security/tools/*
chmod 0740 %{buildroot}%{product_dir}/plugins/opensearch-security/tools/*.sh
fi
# Pre-populate the folders to ensure rpm build success even without all plugins
mkdir -p %{buildroot}%{config_dir}/opensearch-observability
Expand Down Expand Up @@ -192,9 +193,7 @@ exit 0

# Wazuh additional files
%attr(440, %{name}, %{name}) %{product_dir}/VERSION
%attr(750, %{name}, %{name}) %{product_dir}/bin/indexer-security-init.sh
%attr(750, %{name}, %{name}) %{product_dir}/bin/indexer-ism-init.sh
%attr(750, %{name}, %{name}) %{product_dir}/bin/indexer-init.sh
%attr(660, %{name}, %{name}) %{config_dir}/wazuh-template.json

%changelog
* Thu Mar 28 2024 support <info@wazuh.com> - 4.9.0
Expand Down
22 changes: 22 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ while getopts ":h:v:q:s:o:p:a:d:r:" arg; do
r)
REVISION=$OPTARG
;;
b)
BRANCH=$OPTARG
;;
AlexRuiz7 marked this conversation as resolved.
Show resolved Hide resolved
:)
echo "Error: -${OPTARG} requires an argument"
usage
Expand All @@ -74,6 +77,7 @@ fi

[ -z "$OUTPUT" ] && OUTPUT=artifacts


echo "Creating output directory $OUTPUT/maven/org/opensearch if it doesn't already exist"
mkdir -p "$OUTPUT/maven/org/opensearch"

Expand All @@ -96,6 +100,22 @@ cp -r ./build/local-test-repo/org/opensearch "${OUTPUT}"/maven/org
[ -z "$ARCHITECTURE" ] && ARCHITECTURE=$(uname -m)
[ -z "$DISTRIBUTION" ] && DISTRIBUTION="tar"
[ -z "$REVISION" ] && REVISION="1"
[ -z "$BRANCH" ] && BRANCH="master"

function download_template()
{
echo "Downloading wazuh-template.json"
local download_url
download_url='https://raw.githubusercontent.com/wazuh/wazuh/$BRANCH/extensions/elasticsearch/7.x/'
curl -s ${download_url}wazuh-template.json -o distribution/src/config/wazuh-template.json
AlexRuiz7 marked this conversation as resolved.
Show resolved Hide resolved

if [ $? -ne 0 ]; then
echo "Unable to download wazuh-template.json"
exit 1
fi

echo "Successfully downloaded wazuh-template.json"
}

case $PLATFORM-$DISTRIBUTION-$ARCHITECTURE in
linux-tar-x64|darwin-tar-x64)
Expand Down Expand Up @@ -162,6 +182,8 @@ esac

echo "Building OpenSearch for $PLATFORM-$DISTRIBUTION-$ARCHITECTURE"

download_template

./gradlew ":distribution:$TYPE:$TARGET:assemble" -Dbuild.snapshot="$SNAPSHOT" -Dbuild.version_qualifier="$QUALIFIER"

# Copy artifact to dist folder in bundle build output
Expand Down