forked from opensearch-project/opensearch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·110 lines (101 loc) · 4.03 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/bash
# Copyright OpenSearch Contributors
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.
set -ex
function usage() {
echo "Usage: $0 [args]"
echo ""
echo "Arguments:"
echo -e "-v VERSION\t[Required] OpenSearch version."
echo -e "-s SNAPSHOT\t[Optional] Build a snapshot, default is 'false'."
echo -e "-p PLATFORM\t[Optional] Platform, default is 'uname -s'."
echo -e "-a ARCHITECTURE\t[Optional] Build architecture, default is 'uname -m'."
echo -e "-d DISTRIBUTION\t[Optional] Distribution, default is 'tar'."
echo -e "-f ARTIFACTS\t[Optional] Location of build artifacts."
echo -e "-o OUTPUT\t[Optional] Output path."
echo -e "-h help"
}
while getopts ":h:v:s:o:p:a:d:f:" arg; do
case $arg in
h)
usage
exit 1
;;
v)
VERSION=$OPTARG
;;
s)
SNAPSHOT=$OPTARG
;;
o)
OUTPUT=$OPTARG
;;
p)
PLATFORM=$OPTARG
;;
a)
ARCHITECTURE=$OPTARG
;;
d)
DISTRIBUTION=$OPTARG
;;
f)
ARTIFACTS=$OPTARG
;;
:)
echo "Error: -${OPTARG} requires an argument"
usage
exit 1
;;
?)
echo "Invalid option: -${arg}"
exit 1
;;
esac
done
if [ -z "$VERSION" ]; then
echo "Error: missing version."
usage
exit 1
fi
if ! command -v yq > /dev/null; then
echo "Error: yq not found, please install v4 version of yq"
exit 1
fi
[ -z "$SNAPSHOT" ] && SNAPSHOT="false"
[ -z "$PLATFORM" ] && PLATFORM=$(uname -s | awk '{print tolower($0)}')
[ -z "$ARCHITECTURE" ] && ARCHITECTURE=`uname -m`
[ -z "$DISTRIBUTION" ] && DISTRIBUTION="tar"
# Make sure the cwd is where the script is located
DIR="$(dirname "$0")"
echo $DIR
cd $DIR
## Copy the tar installation script into the bundle
MAJOR_VERSION=`echo $VERSION | cut -d. -f1`
if [ "$DISTRIBUTION" = "tar" ]; then
cp -v ../../../scripts/startup/tar/linux/opensearch-tar-install.sh "$OUTPUT/"
elif [ "$DISTRIBUTION" = "deb" ] || [ "$DISTRIBUTION" = "rpm" ]; then
cp -va ../../../scripts/pkg/service_templates/opensearch/* "$OUTPUT/../"
if [ "$MAJOR_VERSION" = "1" ]; then
cp -va ../../../scripts/pkg/build_templates/legacy/opensearch/$DISTRIBUTION/* "$OUTPUT/../"
elif [ "$MAJOR_VERSION" = "2" ]; then
cp -va ../../../scripts/pkg/build_templates/current/opensearch/$DISTRIBUTION/* "$OUTPUT/../"
else
cp -va ../../../scripts/pkg/build_templates/current/opensearch/$DISTRIBUTION/* "$OUTPUT/../"
OS_REF=`yq -e '.components[] | select(.name == "OpenSearch") | .ref' ../../../manifests/$VERSION/opensearch-$VERSION.yml`
curl -SfL "https://raw.githubusercontent.com/opensearch-project/OpenSearch/$OS_REF/distribution/packages/src/common/env/opensearch" -o "$OUTPUT/../etc/sysconfig/opensearch" || { echo "Failed to download env file"; exit 1; }
curl -SfL "https://raw.githubusercontent.com/opensearch-project/OpenSearch/$OS_REF/distribution/packages/src/common/systemd/opensearch.service" -o "$OUTPUT/../usr/lib/systemd/system/opensearch.service" || { echo "Failed to download env file"; exit 1; }
# k-NN lib setups
echo -e "\n\n################################" >> "$OUTPUT/../etc/sysconfig/opensearch"
echo -e "# Plugin properties" >> "$OUTPUT/../etc/sysconfig/opensearch"
echo -e "################################" >> "$OUTPUT/../etc/sysconfig/opensearch"
echo -e "\n# k-NN Lib Path" >> "$OUTPUT/../etc/sysconfig/opensearch"
echo "LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/usr/share/opensearch/plugins/opensearch-knn/lib" >> "$OUTPUT/../etc/sysconfig/opensearch"
fi
elif [ "$DISTRIBUTION" = "zip" ] && [ "$PLATFORM" = "windows" ]; then
cp -v ../../../scripts/startup/zip/windows/opensearch-windows-install.bat "$OUTPUT/"
fi