2017-09-19 04:07:39 -04: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
|
|
|
# Checks that X-Pack files are correctly installed
|
2017-09-19 04:07:39 -04:00
|
|
|
verify_xpack_installation() {
|
2018-01-25 04:20:52 -05:00
|
|
|
local name="x-pack"
|
2017-09-19 04:07:39 -04:00
|
|
|
local user="$ESPLUGIN_COMMAND_USER"
|
|
|
|
local group="$ESPLUGIN_COMMAND_USER"
|
|
|
|
|
2018-01-25 04:20:52 -05:00
|
|
|
# Verify binary files
|
2018-02-23 11:03:17 -05:00
|
|
|
# nocommit: already verified by "main" package verification
|
|
|
|
#assert_file "$ESHOME/bin" d $user $group 755
|
2018-01-25 04:20:52 -05:00
|
|
|
local binaryFiles=(
|
2018-04-10 18:16:30 -04:00
|
|
|
'elasticsearch-certgen'
|
|
|
|
'elasticsearch-certgen.bat'
|
2018-04-10 18:57:08 -04:00
|
|
|
'elasticsearch-certutil'
|
|
|
|
'elasticsearch-certutil.bat'
|
2018-04-11 11:27:16 -04:00
|
|
|
'elasticsearch-croneval'
|
|
|
|
'elasticsearch-croneval.bat'
|
2018-01-25 04:20:52 -05:00
|
|
|
'migrate'
|
|
|
|
'migrate.bat'
|
|
|
|
'saml-metadata'
|
|
|
|
'saml-metadata.bat'
|
2018-04-11 11:21:15 -04:00
|
|
|
'elasticsearch-setup-passwords'
|
|
|
|
'elasticsearch-setup-passwords.bat'
|
2018-04-11 11:29:57 -04:00
|
|
|
'elasticsearch-sql-cli'
|
|
|
|
'elasticsearch-sql-cli.bat'
|
|
|
|
"elasticsearch-sql-cli-$(cat version).jar" # This jar is executable so we pitch it in bin so folks will find it
|
2018-01-25 04:20:52 -05: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 04:07:39 -04:00
|
|
|
|
2018-02-23 11:03:17 -05:00
|
|
|
local binaryFilesCount=5 # start with oss distro number
|
2018-01-25 04:20:52 -05:00
|
|
|
for binaryFile in ${binaryFiles[@]}; do
|
2018-02-23 11:03:17 -05:00
|
|
|
echo "checking for bin file ${binaryFile}"
|
|
|
|
assert_file "$ESHOME/bin/${binaryFile}" f $user $group 755
|
2018-01-25 04:20:52 -05:00
|
|
|
binaryFilesCount=$(( binaryFilesCount + 1 ))
|
|
|
|
done
|
2018-02-23 11:03:17 -05:00
|
|
|
ls "$ESHOME/bin/"
|
|
|
|
# nocommit: decide whether to check the files added by the distribution, not part of xpack...
|
|
|
|
#assert_number_of_files "$ESHOME/bin/" $binaryFilesCount
|
2018-01-25 04:20:52 -05:00
|
|
|
|
|
|
|
# Verify config files
|
2018-02-23 11:03:17 -05:00
|
|
|
# nocommit: already verified by "main" package verification
|
|
|
|
#assert_file "$ESCONFIG" d $user elasticsearch 755
|
2018-01-25 04:20:52 -05:00
|
|
|
local configFiles=(
|
|
|
|
'users'
|
|
|
|
'users_roles'
|
|
|
|
'roles.yml'
|
|
|
|
'role_mapping.yml'
|
|
|
|
'log4j2.properties'
|
|
|
|
)
|
|
|
|
|
2018-02-23 11:03:17 -05:00
|
|
|
local configFilesCount=2 # start with ES files, excluding log4j2
|
2018-01-25 04:20:52 -05:00
|
|
|
for configFile in ${configFiles[@]}; do
|
2018-02-23 11:03:17 -05:00
|
|
|
assert_file "$ESCONFIG/${configFile}" f $user elasticsearch 660
|
2018-01-25 04:20:52 -05:00
|
|
|
configFilesCount=$(( configFilesCount + 1 ))
|
|
|
|
done
|
2018-02-23 11:03:17 -05:00
|
|
|
# nocommit: decide whether to check the files added by the distribution, not part of xpack...
|
|
|
|
#assert_number_of_files "$ESCONFIG/" $configFilesCount
|
2018-01-25 04:20:52 -05:00
|
|
|
|
|
|
|
# Read the $name.expected file that contains all the expected
|
|
|
|
# plugins for the meta plugin
|
|
|
|
while read plugin; do
|
2018-02-23 11:03:17 -05:00
|
|
|
assert_module_or_plugin_directory "$ESMODULES/$name/$plugin"
|
|
|
|
assert_file_exist "$ESMODULES/$name/$plugin/$plugin"*".jar"
|
|
|
|
assert_file_exist "$ESMODULES/$name/$plugin/plugin-descriptor.properties"
|
|
|
|
assert_file_exist "$ESMODULES/$name/$plugin/plugin-security.policy"
|
2018-01-25 04:20:52 -05:00
|
|
|
done </project/build/plugins/$name.expected
|
2017-09-19 04:07:39 -04: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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-14 22:40:51 -05:00
|
|
|
generate_trial_license() {
|
|
|
|
sudo -E -u $ESPLUGIN_COMMAND_USER sh <<"NODE_SETTINGS"
|
|
|
|
cat >> $ESCONFIG/elasticsearch.yml <<- EOF
|
|
|
|
xpack.license.self_generated.type: trial
|
2018-03-24 15:36:05 -04:00
|
|
|
xpack.security.enabled: true
|
2018-02-14 22:40:51 -05:00
|
|
|
EOF
|
|
|
|
NODE_SETTINGS
|
|
|
|
}
|
|
|
|
|
2017-09-19 04:07:39 -04:00
|
|
|
wait_for_xpack() {
|
2017-09-21 04:12:07 -04:00
|
|
|
local host=${1:-localhost}
|
2017-10-11 05:34:33 -04:00
|
|
|
local port=${2:-9200}
|
2018-02-13 13:56:17 -05:00
|
|
|
local listening=1
|
2018-02-12 05:35:46 -05:00
|
|
|
for i in {1..60}; do
|
2018-02-13 13:56:17 -05:00
|
|
|
if test_port "$host" "$port"; then
|
|
|
|
listening=0
|
|
|
|
break
|
|
|
|
else
|
|
|
|
sleep 1
|
|
|
|
fi
|
2017-09-19 04:07:39 -04:00
|
|
|
done
|
2018-02-12 05:35:46 -05:00
|
|
|
|
2018-02-13 13:56:17 -05:00
|
|
|
[ "$listening" -eq 0 ] || {
|
|
|
|
echo "Looks like elasticsearch with x-pack never started."
|
|
|
|
debug_collect_logs
|
|
|
|
false
|
|
|
|
}
|
2017-12-12 11:05:51 -05:00
|
|
|
}
|