forked from sscarduzio/elasticsearch-readonlyrest-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-ror-es-using-api.sh
More file actions
executable file
·40 lines (33 loc) · 1.12 KB
/
install-ror-es-using-api.sh
File metadata and controls
executable file
·40 lines (33 loc) · 1.12 KB
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
#!/bin/bash
verlte() {
local v1="$1"
local v2="${2%%[-+]*}" # Strip suffix from second argument in order to support -pre versions
[ "$v1" = "$(echo -e "$v1\n$v2" | sort -V | head -n1)" ]
}
if [[ -z "$ES_VERSION" ]]; then
echo "No ES_VERSION variable is set"
exit 1
fi
if [[ ! -v ROR_VERSION || -z "$ROR_VERSION" ]]; then
echo "No ROR_VERSION variable is set"
exit 3
fi
echo "Installing ES ROR $ROR_VERSION..."
/usr/share/elasticsearch/bin/elasticsearch-plugin install --batch "https://api.beshu.tech/download/es?esVersion=$ES_VERSION&pluginVersion=$ROR_VERSION&email=ror-sandbox%40readonlyrest.com"
# Set Java path based on ES version
if verlte "7.0.0" "$ES_VERSION"; then
JAVA_BIN_PATH="/usr/share/elasticsearch/jdk/bin/java"
elif verlte "6.7.0" "$ES_VERSION"; then
JAVA_BIN_PATH="$JAVA_HOME/bin/java"
else
echo "Unsupported ES version: $ES_VERSION"
exit 4
fi
# Set OPTIONS based on ROR version
if verlte "1.64.0" "$ROR_VERSION"; then
OPTIONS="--I_UNDERSTAND_AND_ACCEPT_ES_PATCHING=yes"
else
OPTIONS=""
fi
$JAVA_BIN_PATH -jar /usr/share/elasticsearch/plugins/readonlyrest/ror-tools.jar patch $OPTIONS
echo "DONE!"