Skip to content

Commit d28a9c7

Browse files
committed
Create script to build tar artifact
Script to download logstash oss and install latest opensearch plugin from rubygems.org Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>
1 parent de336ad commit d28a9c7

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

release/tar/generate-artifact.sh

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#!/bin/bash
2+
3+
# Copyright OpenSearch Contributors
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
# This is intended to be run the plugin's root directory. `release/tar`
7+
set -e
8+
9+
function usage() {
10+
echo ""
11+
echo "This script is used to generate the Logstash OSS tar artifact by installing logstash output opensearch plugin."
12+
echo "--------------------------------------------------------------------------"
13+
echo "Usage: $0 [args]"
14+
echo ""
15+
echo "Required arguments:"
16+
echo -e "-v VERSION \tSpecify the Logstash OSS version number that you are installing latest output plugin, e.g. '7.14.2'."
17+
echo -e "-p PLATFORM \tSpecify the platform type you are building against, e.g. 'linux, macos'."
18+
echo -e "-a ARCHITECTURE \tSpecify the architecture type you are building against, e.g. 'x64, arm64'."
19+
echo -e "-t TARGET DIRECTORY \tSpecify the location where you like to generate artifact."
20+
echo -e "-h \tPrint this message."
21+
echo ""
22+
echo "--------------------------------------------------------------------------"
23+
}
24+
25+
while getopts ":hv:a:t:p:" arg; do
26+
case $arg in
27+
h)
28+
usage
29+
exit 1
30+
;;
31+
v)
32+
VERSION=$OPTARG
33+
;;
34+
p)
35+
PLATFORM=$OPTARG
36+
;;
37+
a)
38+
ARCHITECTURE=$OPTARG
39+
;;
40+
t)
41+
TARGET_DIRECTORY=$OPTARG
42+
;;
43+
:)
44+
echo "-${OPTARG} requires an argument"
45+
usage
46+
exit 1
47+
;;
48+
?)
49+
echo "Invalid option: -${arg}"
50+
exit 1
51+
;;
52+
esac
53+
done
54+
55+
# Validate the required parameters to present
56+
if [ -z "$VERSION" ] || [ -z "$PLATFORM" ] || [ -z "$ARCHITECTURE" ] || [ -z "$TARGET_DIRECTORY" ]; then
57+
echo "You must specify '-v VERSION', '-p PLATFORM', '-a ARCHITECTURE', '-t TARGET_DIRECTORY'"
58+
usage
59+
exit 1
60+
fi
61+
if [ "$ARCHITECTURE" != "x64" ] && [ "$ARCHITECTURE" != "arm64" ]; then
62+
echo "We only support 'x64' and 'arm64' as architecture name for -a parameter"
63+
exit 1
64+
fi
65+
if [ "$PLATFORM" != "macos" ] && [ "$PLATFORM" != "linux" ]; then
66+
echo "We only support 'macos' and 'linux' as platform name for -p parameter"
67+
exit 1
68+
fi
69+
if [ "$PLATFORM" == "macos" ] && [ "$ARCHITECTURE" == "arm64" ]; then
70+
echo "We don't support $ARCHITECTURE for $PLATFORM at this moment"
71+
exit 1
72+
fi
73+
74+
# map user input to logstash oss for architecture
75+
76+
if [ "$ARCHITECTURE" == "x64" ]; then
77+
LOGSTASH_OSS_ARCHITECTURE="x86_64"
78+
elif [ "$ARCHITECTURE" == "arm64" ]; then
79+
LOGSTASH_OSS_ARCHITECTURE="aarch64"
80+
fi
81+
82+
# map user input to logstash oss for platform
83+
84+
if [ "$PLATFORM" == "macos" ]; then
85+
LOGSTASH_OSS_PLATFORM="darwin"
86+
elif [ "$PLATFORM" == "linux" ]; then
87+
LOGSTASH_OSS_PLATFORM=$PLATFORM
88+
fi
89+
90+
LOGSTASH_OSS_ARTIFACT_NAME=logstash-oss-$VERSION-$LOGSTASH_OSS_PLATFORM-$LOGSTASH_OSS_ARCHITECTURE.tar.gz
91+
GENERATED_ARTIFACT_NAME=logstash-oss-with-opensearch-output-plugin-$VERSION-$PLATFORM-$ARCHITECTURE.tar.gz
92+
93+
echo 'downloading logstash oss'
94+
wget https://artifacts.elastic.co/downloads/logstash/$LOGSTASH_OSS_ARTIFACT_NAME -P $TARGET_DIRECTORY/;
95+
cd $TARGET_DIRECTORY;
96+
tar xzf $LOGSTASH_OSS_ARTIFACT_NAME;
97+
98+
echo 'installing latest opensearch output plugin'
99+
logstash-$VERSION/bin/logstash-plugin install logstash-output-opensearch;
100+
101+
echo 'bundling logstash oss with latest opensearch output plugin'
102+
tar -czf $GENERATED_ARTIFACT_NAME logstash-$VERSION;
103+
104+
echo 'Artifact path:'$TARGET_DIRECTORY/$GENERATED_ARTIFACT_NAME;
105+

0 commit comments

Comments
 (0)