2017-09-19 10:07:39 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
|
|
# or more contributor license agreements. Licensed under the Elastic License;
|
|
|
|
# you may not use this file except in compliance with the Elastic License.
|
|
|
|
|
2017-12-12 11:05:51 -05:00
|
|
|
install_xpack() {
|
2018-01-25 10:20:52 +01:00
|
|
|
install_meta_plugin x-pack
|
2017-12-12 11:05:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
# Checks that X-Pack files are correctly installed
|
2017-09-19 10:07:39 +02:00
|
|
|
verify_xpack_installation() {
|
2018-01-25 10:20:52 +01:00
|
|
|
local name="x-pack"
|
2017-09-19 10:07:39 +02:00
|
|
|
local user="$ESPLUGIN_COMMAND_USER"
|
|
|
|
local group="$ESPLUGIN_COMMAND_USER"
|
|
|
|
|
2018-01-25 10:20:52 +01:00
|
|
|
# Verify binary files
|
|
|
|
assert_file "$ESHOME/bin/$name" d $user $group 755
|
|
|
|
local binaryFiles=(
|
|
|
|
'certgen'
|
|
|
|
'certgen.bat'
|
|
|
|
'certutil'
|
|
|
|
'certutil.bat'
|
|
|
|
'croneval'
|
|
|
|
'croneval.bat'
|
|
|
|
'migrate'
|
|
|
|
'migrate.bat'
|
|
|
|
'saml-metadata'
|
|
|
|
'saml-metadata.bat'
|
|
|
|
'setup-passwords'
|
|
|
|
'setup-passwords.bat'
|
2018-01-29 15:42:01 -07:00
|
|
|
'sql-cli'
|
|
|
|
'sql-cli.bat'
|
2018-02-06 14:20:44 -05:00
|
|
|
"sql-cli-$(cat version).jar" # This jar is executable so we pitch it in bin so folks will find it
|
2018-01-25 10:20:52 +01:00
|
|
|
'syskeygen'
|
|
|
|
'syskeygen.bat'
|
|
|
|
'users'
|
|
|
|
'users.bat'
|
|
|
|
'x-pack-env'
|
|
|
|
'x-pack-env.bat'
|
|
|
|
'x-pack-security-env'
|
|
|
|
'x-pack-security-env.bat'
|
|
|
|
'x-pack-watcher-env'
|
|
|
|
'x-pack-watcher-env.bat'
|
|
|
|
)
|
2017-09-19 10:07:39 +02:00
|
|
|
|
2018-01-25 10:20:52 +01:00
|
|
|
local binaryFilesCount=0
|
|
|
|
for binaryFile in ${binaryFiles[@]}; do
|
2018-02-06 14:20:44 -05:00
|
|
|
echo "checking for bin file $name/${binaryFile}"
|
2018-01-25 10:20:52 +01:00
|
|
|
assert_file "$ESHOME/bin/$name/${binaryFile}" f $user $group 755
|
|
|
|
binaryFilesCount=$(( binaryFilesCount + 1 ))
|
|
|
|
done
|
|
|
|
assert_number_of_files "$ESHOME/bin/$name/" $binaryFilesCount
|
|
|
|
|
|
|
|
# Verify config files
|
|
|
|
assert_file "$ESCONFIG/$name" d $user elasticsearch 750
|
|
|
|
local configFiles=(
|
|
|
|
'users'
|
|
|
|
'users_roles'
|
|
|
|
'roles.yml'
|
|
|
|
'role_mapping.yml'
|
|
|
|
'log4j2.properties'
|
|
|
|
)
|
|
|
|
|
|
|
|
local configFilesCount=0
|
|
|
|
for configFile in ${configFiles[@]}; do
|
|
|
|
assert_file "$ESCONFIG/$name/${configFile}" f $user elasticsearch 660
|
|
|
|
configFilesCount=$(( configFilesCount + 1 ))
|
|
|
|
done
|
|
|
|
assert_number_of_files "$ESCONFIG/$name/" $configFilesCount
|
|
|
|
|
|
|
|
# Verify keystore creation
|
2017-09-19 10:07:39 +02:00
|
|
|
assert_file "$ESCONFIG/elasticsearch.keystore" f $user elasticsearch 660
|
2018-01-25 10:20:52 +01:00
|
|
|
|
|
|
|
# Read the $name.expected file that contains all the expected
|
|
|
|
# plugins for the meta plugin
|
|
|
|
while read plugin; do
|
|
|
|
assert_module_or_plugin_directory "$ESPLUGINS/$name/$plugin"
|
|
|
|
assert_file_exist "$ESPLUGINS/$name/$plugin/$plugin"*".jar"
|
|
|
|
assert_file_exist "$ESPLUGINS/$name/$plugin/plugin-descriptor.properties"
|
|
|
|
assert_file_exist "$ESPLUGINS/$name/$plugin/plugin-security.policy"
|
|
|
|
done </project/build/plugins/$name.expected
|
2017-09-19 10:07:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
assert_number_of_files() {
|
|
|
|
local directory=$1
|
|
|
|
local expected=$2
|
|
|
|
|
|
|
|
local count=$(ls "$directory" | wc -l)
|
|
|
|
[ "$count" -eq "$expected" ] || {
|
|
|
|
echo "Expected $expected files in $directory but found: $count"
|
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wait_for_xpack() {
|
2017-09-21 10:12:07 +02:00
|
|
|
local host=${1:-localhost}
|
2017-10-11 11:34:33 +02:00
|
|
|
local port=${2:-9200}
|
2017-09-19 10:07:39 +02:00
|
|
|
for i in {1..30}; do
|
2017-09-21 10:12:07 +02:00
|
|
|
echo "GET / HTTP/1.0" > /dev/tcp/$host/$port && break || sleep 1;
|
2017-09-19 10:07:39 +02:00
|
|
|
done
|
2017-12-12 11:05:51 -05:00
|
|
|
}
|