2016-05-18 11:03:00 -04:00
|
|
|
#!/bin/bash
|
2015-08-21 16:05:50 -04:00
|
|
|
|
2017-04-26 10:40:35 -04:00
|
|
|
# This file contains some utilities to test the elasticsearch
|
|
|
|
# tar distribution.
|
2015-08-21 16:05:50 -04:00
|
|
|
|
|
|
|
# WARNING: This testing file must be executed as root and can
|
2017-04-26 10:40:35 -04:00
|
|
|
# dramatically change your system. It should only be executed
|
|
|
|
# in a throw-away VM like those made by the Vagrantfile at
|
|
|
|
# the root of the Elasticsearch source code. This should
|
|
|
|
# cause the script to fail if it is executed any other way:
|
|
|
|
[ -f /etc/is_vagrant_vm ] || {
|
|
|
|
>&2 echo "must be run on a vagrant VM"
|
|
|
|
exit 1
|
|
|
|
}
|
2015-08-21 16:05:50 -04:00
|
|
|
|
|
|
|
# Licensed to Elasticsearch under one or more contributor
|
|
|
|
# license agreements. See the NOTICE file distributed with
|
|
|
|
# this work for additional information regarding copyright
|
|
|
|
# ownership. Elasticsearch licenses this file to you under
|
|
|
|
# the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
# not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing,
|
|
|
|
# software distributed under the License is distributed on an
|
|
|
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
# KIND, either express or implied. See the License for the
|
|
|
|
# specific language governing permissions and limitations
|
|
|
|
# under the License.
|
|
|
|
|
|
|
|
|
|
|
|
# Install the tar.gz archive
|
|
|
|
install_archive() {
|
|
|
|
export ESHOME=${1:-/tmp/elasticsearch}
|
|
|
|
|
2018-04-26 09:58:41 -04:00
|
|
|
local version=$(cat version)
|
|
|
|
|
2015-08-21 16:05:50 -04:00
|
|
|
echo "Unpacking tarball to $ESHOME"
|
|
|
|
rm -rf /tmp/untar
|
|
|
|
mkdir -p /tmp/untar
|
2019-01-29 14:18:30 -05:00
|
|
|
tar -xzpf "${PACKAGE_NAME}-${version}-linux-x86_64.tar.gz" -C /tmp/untar
|
2015-08-21 16:05:50 -04:00
|
|
|
|
|
|
|
find /tmp/untar -depth -type d -name 'elasticsearch*' -exec mv {} "$ESHOME" \; > /dev/null
|
|
|
|
|
|
|
|
# ES cannot run as root so create elasticsearch user & group if needed
|
|
|
|
if ! getent group "elasticsearch" > /dev/null 2>&1 ; then
|
|
|
|
if is_dpkg; then
|
|
|
|
addgroup --system "elasticsearch"
|
|
|
|
else
|
|
|
|
groupadd -r "elasticsearch"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if ! id "elasticsearch" > /dev/null 2>&1 ; then
|
|
|
|
if is_dpkg; then
|
|
|
|
adduser --quiet --system --no-create-home --ingroup "elasticsearch" --disabled-password --shell /bin/false "elasticsearch"
|
|
|
|
else
|
|
|
|
useradd --system -M --gid "elasticsearch" --shell /sbin/nologin --comment "elasticsearch user" "elasticsearch"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
chown -R elasticsearch:elasticsearch "$ESHOME"
|
|
|
|
export_elasticsearch_paths
|
|
|
|
}
|
|
|
|
|
|
|
|
# Move the unzipped tarball to another location.
|
|
|
|
move_elasticsearch() {
|
|
|
|
local oldhome="$ESHOME"
|
|
|
|
export ESHOME="$1"
|
|
|
|
rm -rf "$ESHOME"
|
|
|
|
mv "$oldhome" "$ESHOME"
|
|
|
|
export_elasticsearch_paths
|
|
|
|
}
|
|
|
|
|
|
|
|
# Export some useful paths.
|
|
|
|
export_elasticsearch_paths() {
|
2016-03-16 19:29:16 -04:00
|
|
|
export ESMODULES="$ESHOME/modules"
|
2015-08-21 16:05:50 -04:00
|
|
|
export ESPLUGINS="$ESHOME/plugins"
|
|
|
|
export ESCONFIG="$ESHOME/config"
|
2015-09-01 22:12:18 -04:00
|
|
|
export ESSCRIPTS="$ESCONFIG/scripts"
|
|
|
|
export ESDATA="$ESHOME/data"
|
|
|
|
export ESLOG="$ESHOME/logs"
|
2018-04-26 09:58:41 -04:00
|
|
|
|
|
|
|
export PACKAGE_NAME=${PACKAGE_NAME:-"elasticsearch-oss"}
|
2015-09-01 22:12:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
# Checks that all directories & files are correctly installed
|
|
|
|
# after a archive (tar.gz/zip) install
|
|
|
|
verify_archive_installation() {
|
2016-10-24 03:42:03 -04:00
|
|
|
assert_file "$ESHOME" d elasticsearch elasticsearch 755
|
|
|
|
assert_file "$ESHOME/bin" d elasticsearch elasticsearch 755
|
|
|
|
assert_file "$ESHOME/bin/elasticsearch" f elasticsearch elasticsearch 755
|
2017-07-29 16:14:25 -04:00
|
|
|
assert_file "$ESHOME/bin/elasticsearch-env" f elasticsearch elasticsearch 755
|
|
|
|
assert_file "$ESHOME/bin/elasticsearch-keystore" f elasticsearch elasticsearch 755
|
2016-10-24 03:42:03 -04:00
|
|
|
assert_file "$ESHOME/bin/elasticsearch-plugin" f elasticsearch elasticsearch 755
|
2018-09-19 04:28:22 -04:00
|
|
|
assert_file "$ESHOME/bin/elasticsearch-shard" f elasticsearch elasticsearch 755
|
2019-01-24 13:25:55 -05:00
|
|
|
assert_file "$ESHOME/bin/elasticsearch-node" f elasticsearch elasticsearch 755
|
2016-10-24 03:42:03 -04:00
|
|
|
assert_file "$ESCONFIG" d elasticsearch elasticsearch 755
|
|
|
|
assert_file "$ESCONFIG/elasticsearch.yml" f elasticsearch elasticsearch 660
|
|
|
|
assert_file "$ESCONFIG/jvm.options" f elasticsearch elasticsearch 660
|
|
|
|
assert_file "$ESCONFIG/log4j2.properties" f elasticsearch elasticsearch 660
|
2016-11-01 15:14:24 -04:00
|
|
|
assert_file "$ESPLUGINS" d elasticsearch elasticsearch 755
|
2016-10-24 03:42:03 -04:00
|
|
|
assert_file "$ESHOME/lib" d elasticsearch elasticsearch 755
|
2017-12-03 08:33:21 -05:00
|
|
|
assert_file "$ESHOME/logs" d elasticsearch elasticsearch 755
|
2016-10-24 03:42:03 -04:00
|
|
|
assert_file "$ESHOME/NOTICE.txt" f elasticsearch elasticsearch 644
|
|
|
|
assert_file "$ESHOME/LICENSE.txt" f elasticsearch elasticsearch 644
|
|
|
|
assert_file "$ESHOME/README.textile" f elasticsearch elasticsearch 644
|
2018-03-12 12:48:00 -04:00
|
|
|
assert_file_not_exist "$ESCONFIG/elasticsearch.keystore"
|
2015-08-21 16:05:50 -04:00
|
|
|
}
|