6.4.2-debian-9-r21 release

This commit is contained in:
Bitnami Bot 2018-11-02 12:06:36 +00:00
parent 08246e18f2
commit 3e120d8f18
8 changed files with 380 additions and 244 deletions

View File

@ -1,4 +1,4 @@
FROM bitnami/minideb-extras-base:stretch-r55
FROM bitnami/minideb-extras-base:stretch-r63
LABEL maintainer "Bitnami <containers@bitnami.com>"
ENV BITNAMI_PKG_CHMOD="-R g+rwX" \
@ -15,7 +15,7 @@ RUN . ./libcomponent.sh && component_unpack "elasticsearch" "6.4.2-4" --checksum
COPY rootfs /
RUN /prepare.sh
ENV BITNAMI_APP_NAME="elasticsearch" \
BITNAMI_IMAGE_VERSION="6.4.2-debian-9-r20" \
BITNAMI_IMAGE_VERSION="6.4.2-debian-9-r21" \
ELASTICSEARCH_BIND_ADDRESS="" \
ELASTICSEARCH_CLUSTER_HOSTS="" \
ELASTICSEARCH_CLUSTER_NAME="elasticsearch-cluster" \

View File

@ -4,15 +4,22 @@ set -o errexit
set -o nounset
set -o pipefail
#set -o xtrace
# shellcheck disable=SC1091
# Load libraries
. /libbitnami.sh
. /libelasticsearch.sh && eval "$(elasticsearch_env)"
. /libelasticsearch.sh
# Load Elasticsearch env. variables
eval "$(elasticsearch_env)"
print_welcome_page
if [ "$*" = "/run.sh" ]; then
if [[ "$*" = "/run.sh" ]]; then
info "** Starting Elasticsearch setup **"
/setup.sh
info "** Elasticsearch setup finished! **"
fi
echo ""
exec "$@"

View File

@ -1,5 +1,10 @@
#!/bin/bash -e
#!/bin/bash
#
# Bitnami Elasticsearch library
# shellcheck disable=SC1091
# Load Generic Libraries
. /libfile.sh
. /liblog.sh
. /libnet.sh
@ -7,207 +12,89 @@
. /libservice.sh
. /libvalidations.sh
# Functions
# Echo env vars for elasticsearch global configuration.
elasticsearch_env() {
cat <<"EOF"
export ELASTICSEARCH_BASEDIR=/opt/bitnami/elasticsearch
export ELASTICSEARCH_DATADIR=/bitnami/elasticsearch/data
export ELASTICSEARCH_CONFDIR=$ELASTICSEARCH_BASEDIR/config
export ELASTICSEARCH_CONF_FILE=$ELASTICSEARCH_CONFDIR/elasticsearch.yml
export ELASTICSEARCH_TMPDIR=$ELASTICSEARCH_BASEDIR/tmp
export ELASTICSEARCH_LOGDIR=$ELASTICSEARCH_BASEDIR/logs
export PATH=$ELASTICSEARCH_BASEDIR/bin:$PATH
export ELASTICSEARCH_DAEMON_USER=elasticsearch
export ELASTICSEARCH_DAEMON_GROUP=elasticsearch
EOF
}
########################
# Set a configuration setting value
# Globals:
# ELASTICSEARCH_CONF_FILE
# Arguments:
# $1 - key
# $2 - values (array)
# Returns:
# None
#########################
elasticsearch_conf_set() {
local name="${1:?missing key}"
shift
local values=("${@}")
# Validate settings in ELASTICSEARCH_* env vars.
elasticsearch_validate() {
validate_sysctl_key() {
local key=${1:?key is missing}
local value=${2:?value is missing}
local current_value
current_value=$(sysctl -n "$key")
if [[ "$current_value" -lt "$value" ]]; then
error "Invalid kernel settings. Elasticsearch requires at least $key = $value"
exit 1
fi
}
validate_sysctl_key "vm.max_map_count" 262144
validate_sysctl_key "fs.file-max" 65536
for var in ELASTICSEARCH_PORT_NUMBER ELASTICSEARCH_NODE_PORT_NUMBER; do
local value=${!var}
if ! err=$(validate_port "$value"); then
error "The $var environment variable is invalid: $err"
exit 1
fi
done
validate_node_type() {
case "$ELASTICSEARCH_NODE_TYPE" in
coordinating|data|ingest|master)
;;
*)
error "Invalid node type $ELASTICSEARCH_NODE_TYPE. Supported types are 'coordinating/data/ingest/master'"
exit 1
;;
esac
}
if is_boolean_yes "$ELASTICSEARCH_IS_DEDICATED_NODE"; then
validate_node_type
if [[ "${#values[@]}" -eq 0 ]]; then
stderr_print "missing value"
return 1
elif [[ "${#values[@]}" -eq 1 ]]; then
yq w -i "$ELASTICSEARCH_CONF_FILE" "$name" "${values[0]}"
else
for i in "${!values[@]}"; do
yq w -i "$ELASTICSEARCH_CONF_FILE" "$name[$i]" "${values[$i]}"
done
fi
}
# Ensure the elasticsearch volume is initialised.
elasticsearch_initialize() {
configure_node() {
local type=${1}
local is_dedicated_node=${2:-no}
local is_master="false"
local is_data="false"
local is_ingest="false"
if is_boolean_yes "$is_dedicated_node"; then
case "$type" in
coordinating)
;;
data)
is_data="true"
;;
ingest)
is_ingest="true"
;;
master)
is_master="true"
;;
*)
error "Invalid node type $type'"
exit 1
;;
esac
else
is_master="true"
is_data="true"
fi
elasticsearch_conf_set node.master "$is_master"
elasticsearch_conf_set node.data "$is_data"
elasticsearch_conf_set node.ingest "$is_ingest"
}
install_plugins() {
local plugins="${1:-}"
if [ -n "$plugins" ]; then
local plugins_list
plugins_list=$(tr ',;' ' ' <<< "${plugins}")
for plugin in ${plugins_list[@]}; do
info "Installing plugin: $plugin"
elasticsearch-plugin install -b -v "$plugin"
done
fi
}
set_heap_size() {
local heap_size="${1:-}"
if [ -n "$heap_size" ]; then
info "Using specified values for Xmx and Xms heap options..."
else
info "Calculating appropiate Xmx and Xms values..."
local machine_mem=""
machine_mem="$(get_total_memory)"
if [ "$machine_mem" -lt 65536 ]; then
heap_size="$(("$machine_mem" / 2))m"
else
heap_size=32768m
fi
fi
info "Setting '-Xmx${heap_size} -Xms${heap_size}' heap options..."
sed -r -i "s/-Xmx[0-9]+[mg]+/-Xmx${heap_size}/g" "$ELASTICSEARCH_CONFDIR/jvm.options"
sed -r -i "s/-Xms[0-9]+[mg]+/-Xms${heap_size}/g" "$ELASTICSEARCH_CONFDIR/jvm.options"
}
minimal_config() {
info "Setting default configuration"
elasticsearch_conf_set http.port "$ELASTICSEARCH_PORT_NUMBER"
elasticsearch_conf_set path.data "$ELASTICSEARCH_DATADIR"
elasticsearch_conf_set transport.tcp.port "$ELASTICSEARCH_NODE_PORT_NUMBER"
info "Setting cluster configuration"
cluster_configuration
configure_node "$ELASTICSEARCH_NODE_TYPE" "$ELASTICSEARCH_IS_DEDICATED_NODE"
local custom_conf_file="$ELASTICSEARCH_CONFDIR/elasticsearch_custom.yml"
if [ -f "$custom_conf_file" ]; then
info "Applying user configuration"
echo "" >> "$ELASTICSEARCH_CONF_FILE"
cat "$custom_conf_file" >> "$ELASTICSEARCH_CONF_FILE"
fi
set_heap_size "$ELASTICSEARCH_HEAP_SIZE"
}
migrate_old_data() {
warn "Persisted data follows old structure. Migrating to new one..."
warn "Custom configuration files won't be persisted any longer!"
local old_data_dir="$ELASTICSEARCH_DATADIR/elasticsearch"
local old_custom_conf_file="$old_data_dir/conf/elasticsearch_custom.yml"
local custom_conf_file="$ELASTICSEARCH_CONFDIR/elasticsearch_custom.yml"
if [ -f "$old_custom_conf_file" ]; then
info "Adding old custom configuration to user configuration"
echo "" >> "$custom_conf_file"
cat "$old_custom_conf_file" >> "$custom_conf_file"
fi
info "Adapting data to new file structure"
find "$old_data_dir/data" -maxdepth 1 -mindepth 1 -exec mv {} "$ELASTICSEARCH_DATADIR" \;
info "Removing data that is not persisted anymore from persisted directory"
rm -rf "$old_data_dir" "$ELASTICSEARCH_DATADIR/java"
}
if am_i_root; then
ensure_user_exists "$ELASTICSEARCH_DAEMON_USER" "$ELASTICSEARCH_DAEMON_GROUP"
fi
if ! dir_is_empty "$ELASTICSEARCH_DATADIR"; then
info "Detected persisted data from previous deployments"
if [ -d "$ELASTICSEARCH_DATADIR/elasticsearch" -a -f "$ELASTICSEARCH_DATADIR/elasticsearch/.initialized" ]; then
migrate_old_data
fi
fi
for dir in "$ELASTICSEARCH_TMPDIR" "$ELASTICSEARCH_DATADIR" "$ELASTICSEARCH_LOGDIR" "$ELASTICSEARCH_BASEDIR/plugins" "$ELASTICSEARCH_BASEDIR/modules" "$ELASTICSEARCH_CONFDIR/scripts"; do
ensure_dir_exists "$dir"
if am_i_root; then
chown "$ELASTICSEARCH_DAEMON_USER:$ELASTICSEARCH_DAEMON_GROUP" "$dir"
fi
done
minimal_config
install_plugins "$ELASTICSEARCH_PLUGINS"
}
# Checks if elasticsearch is running
########################
# Check if Elasticsearch is running
# Globals:
# ELASTICSEARCH_TMPDIR
# Arguments:
# None
# Returns:
# Boolean
#########################
is_elasticsearch_running() {
local pid
pid="$(get_pid "$ELASTICSEARCH_TMPDIR/elasticsearch.pid")"
pid="$(get_pid_from_file "${ELASTICSEARCH_TMPDIR}/elasticsearch.pid")"
if [ -z "$pid" ]; then
if [[ -z "$pid" ]]; then
false
else
is_service_running "$pid"
fi
}
# Stops elasticsearch
########################
# Stop Elasticsearch
# Globals:
# ELASTICSEARCH_TMPDIR
# Arguments:
# None
# Returns:
# None
#########################
elasticsearch_stop() {
! is_elasticsearch_running && return
debug "Stopping Elasticsearch..."
stop_service_using_pid "$ELASTICSEARCH_TMPDIR/elasticsearch.pid"
}
# Starts elasticsearch
########################
# Start Elasticsearch and wait until it's ready
# Globals:
# ELASTICSEARCH_*
# Arguments:
# None
# Returns:
# None
#########################
elasticsearch_start() {
if is_elasticsearch_running ; then
return
fi
if am_i_root; then
gosu "$ELASTICSEARCH_DAEMON_USER" "$ELASTICSEARCH_BASEDIR/bin/elasticsearch" -d -p "$ELASTICSEARCH_TMPDIR/elasticsearch.pid" -Epath.data="$ELASTICSEARCH_DATADIR" >/dev/null 2>&1 &
is_elasticsearch_running && return
debug "Starting Elasticsearch..."
local command=("${ELASTICSEARCH_BASEDIR}/bin/elasticsearch" "-d" "-p" "${ELASTICSEARCH_TMPDIR}/elasticsearch.pid" "-Epath.data=$ELASTICSEARCH_DATADIR")
am_i_root && command=("gosu" "$ELASTICSEARCH_DAEMON_USER" "${command[@]}")
if [[ "$BITNAMI_DEBUG" = true ]]; then
"${command[@]}" &
else
"$ELASTICSEARCH_BASEDIR/bin/elasticsearch" -d -p "$ELASTICSEARCH_TMPDIR/elasticsearch.pid" -Epath.data="$ELASTICSEARCH_DATADIR" >/dev/null 2>&1 &
"${command[@]}" >/dev/null 2>&1 &
fi
local counter=50
@ -218,70 +105,304 @@ elasticsearch_start() {
sleep 2;
counter=$((counter - 1))
done
local log_result=""
local log_counter=30
local log_file="$ELASTICSEARCH_LOGDIR/elasticsearch.log"
while [ -z "$log_result" ] && [ "$log_counter" -ne 0 ]; do
while [[ -z "$log_result" ]] && [[ "$log_counter" -ne 0 ]]; do
log_counter=$(("$log_counter" - 1))
log_result=$(tail -7 "$log_file" | grep -i "Node" | grep -i "started")
log_result="$(tail -7 "${ELASTICSEARCH_LOGDIR}/elasticsearch.log" | grep -i "Node" | grep -i "started")"
sleep 2
done
}
cluster_configuration() {
########################
# Load global variables used on Elasticsearch configuration
# Globals:
# ELASTICSEARCH_*
# Arguments:
# None
# Returns:
# Series of exports to be used as 'eval' arguments
#########################
elasticsearch_env() {
cat <<"EOF"
export ELASTICSEARCH_BASEDIR="/opt/bitnami/elasticsearch"
export ELASTICSEARCH_DATADIR="/bitnami/elasticsearch/data"
export ELASTICSEARCH_CONFDIR="${ELASTICSEARCH_BASEDIR}/config"
export ELASTICSEARCH_CONF_FILE="${ELASTICSEARCH_CONFDIR}/elasticsearch.yml"
export ELASTICSEARCH_TMPDIR="${ELASTICSEARCH_BASEDIR}/tmp"
export ELASTICSEARCH_LOGDIR="${ELASTICSEARCH_BASEDIR}/logs"
export PATH="${ELASTICSEARCH_BASEDIR}/bin:$PATH"
export ELASTICSEARCH_DAEMON_USER="${ELASTICSEARCH_DAEMON_USER:-elasticsearch}"
export ELASTICSEARCH_DAEMON_GROUP="${ELASTICSEARCH_DAEMON_GROUP:-elasticsearch}"
EOF
}
########################
# Validate kernel settings
# Arguments:
# None
# Returns:
# None
#########################
elasticsearch_validate_kernel() {
# Auxiliary functions
validate_sysctl_key() {
local key="${1:?key is missing}"
local value="${2:?value is missing}"
local current_value
current_value="$(sysctl -n "$key")"
if [[ "$current_value" -lt "$value" ]]; then
error "Invalid kernel settings. Elasticsearch requires at least: $key = $value"
exit 1
fi
}
debug "Validating Kernel settings..."
validate_sysctl_key "vm.max_map_count" 262144
validate_sysctl_key "fs.file-max" 65536
}
########################
# Validate settings in ELASTICSEARCH_* env vars
# Globals:
# ELASTICSEARCH_*
# Arguments:
# None
# Returns:
# None
#########################
elasticsearch_validate() {
# Auxiliary functions
validate_node_type() {
case "$ELASTICSEARCH_NODE_TYPE" in
coordinating|data|ingest|master)
;;
*)
error "Invalid node type $ELASTICSEARCH_NODE_TYPE. Supported types are 'coordinating/data/ingest/master'"
exit 1
esac
}
debug "Validating settings in ELASTICSEARCH_* env vars..."
local validate_port_args=()
! am_i_root && validate_port_args+=("-unprivileged")
for var in "ELASTICSEARCH_PORT_NUMBER" "ELASTICSEARCH_NODE_PORT_NUMBER"; do
if ! err=$(validate_port "${validate_port_args[@]}" "${!var}"); then
error "An invalid port was specified in the environment variable $var: $err"
exit 1
fi
done
is_boolean_yes "$ELASTICSEARCH_IS_DEDICATED_NODE" && validate_node_type
if [[ -n "$ELASTICSEARCH_BIND_ADDRESS" ]] && ! validate_ipv4 "$ELASTICSEARCH_BIND_ADDRESS"; then
error "The Bind Address specified in the environment variable ELASTICSEARCH_BIND_ADDRESS is not a valid IPv4"
exit 1
fi
}
# Bash math operations cannot handle float or complex math operations
calc() {
local expr="${1:?missing expression}"
perl <<<"use POSIX qw/ceil/;print $expr"
}
########################
# Configure Elasticsearch cluster settings
# Globals:
# ELASTICSEARCH_*
# Arguments:
# None
# Returns:
# None
#########################
elasticsearch_cluster_configuration() {
# Auxiliary functions
bind_address() {
if [ -n "$ELASTICSEARCH_BIND_ADDRESS" ]; then
if [[ -n "$ELASTICSEARCH_BIND_ADDRESS" ]]; then
echo "[$ELASTICSEARCH_BIND_ADDRESS, _local_]"
else
echo "0.0.0.0"
fi
}
# Bash math operations cannot handle float or complex math operations
calc() {
local expr="${1:?missing expression}"
perl <<<"use POSIX qw/ceil/;print $expr"
}
info "Configuration Elasticsearch cluster settings..."
elasticsearch_conf_set network.host "$(get_machine_ip)"
elasticsearch_conf_set network.publish_host "$(get_machine_ip)"
elasticsearch_conf_set network.bind_host "$(bind_address)"
elasticsearch_conf_set cluster.name "$ELASTICSEARCH_CLUSTER_NAME"
elasticsearch_conf_set node.name "${ELASTICSEARCH_NODE_NAME:-$(hostname)}"
if [ -n "$ELASTICSEARCH_CLUSTER_HOSTS" ]; then
local host_list
host_list=($(tr ',;' ' ' <<< "$ELASTICSEARCH_CLUSTER_HOSTS"))
if [[ -n "$ELASTICSEARCH_CLUSTER_HOSTS" ]]; then
read -r -a host_list <<< "$(tr ',;' ' ' <<< "$ELASTICSEARCH_CLUSTER_HOSTS")"
elasticsearch_conf_set discovery.zen.ping.unicast.hosts "${host_list[@]}"
elasticsearch_conf_set discovery.initial_state_timeout "5m"
elasticsearch_conf_set gateway.recover_after_nodes "$(calc "ceil(${#host_list[@]}*0.8)")"
elasticsearch_conf_set gateway.expected_nodes "${#host_list[@]}"
if [ -n "$ELASTICSEARCH_MINIMUM_MASTER_NODES" ]; then
info "Setting minimum master nodes for quorum to $ELASTICSEARCH_MINIMUM_MASTER_NODES..."
if [[ -n "$ELASTICSEARCH_MINIMUM_MASTER_NODES" ]]; then
debug "Setting minimum master nodes for quorum to $ELASTICSEARCH_MINIMUM_MASTER_NODES..."
elasticsearch_conf_set discovery.zen.minimum_master_nodes "$ELASTICSEARCH_MINIMUM_MASTER_NODES"
elif [ "${#host_list[@]}" -gt 2 ]; then
elif [[ "${#host_list[@]}" -gt 2 ]]; then
local min_masters=""
min_masters=$((("${#host_list[@]}" / 2) +1))
info "Calculating minimum master nodes for quorum: $min_masters..."
debug "Calculating minimum master nodes for quorum: $min_masters..."
elasticsearch_conf_set discovery.zen.minimum_master_nodes "$min_masters"
fi
fi
}
elasticsearch_conf_set() {
local name="${1:?missing key}"
shift
local values=("${@}")
if [ "${#values[@]}" -eq 0 ]; then
stderr_print "missing value"
return 1
elif [ "${#values[@]}" -eq 1 ]; then
yq w -i "$ELASTICSEARCH_CONF_FILE" "$name" "${values[0]}"
########################
# Configure Elasticsearch node type
# Globals:
# ELASTICSEARCH_*
# Arguments:
# None
# Returns:
# None
#########################
elasticsearch_configure_node_type() {
local is_master="false"
local is_data="false"
local is_ingest="false"
if is_boolean_yes "$ELASTICSEARCH_IS_DEDICATED_NODE"; then
case "$ELASTICSEARCH_NODE_TYPE" in
coordinating)
;;
data)
is_data="true"
;;
ingest)
is_ingest="true"
;;
master)
is_master="true"
;;
*)
error "Invalid node type '$ELASTICSEARCH_NODE_TYPE'"
exit 1
;;
esac
else
for i in "${!values[@]}"; do
yq w -i "$ELASTICSEARCH_CONF_FILE" "$name[$i]" "${values[$i]}"
done
is_master="true"
is_data="true"
fi
debug "Configure Elasticsearch Node type..."
elasticsearch_conf_set node.master "$is_master"
elasticsearch_conf_set node.data "$is_data"
elasticsearch_conf_set node.ingest "$is_ingest"
}
########################
# Configure Elasticsearch Heap Size
# Globals:
# ELASTICSEARCH_*
# Arguments:
# None
# Returns:
# None
#########################
elasticsearch_set_heap_size() {
local heap_size
if [[ -n "$ELASTICSEARCH_HEAP_SIZE" ]]; then
debug "Using specified values for Xmx and Xms heap options..."
heap_size="$ELASTICSEARCH_HEAP_SIZE"
else
debug "Calculating appropiate Xmx and Xms values..."
local machine_mem=""
machine_mem="$(get_total_memory)"
if [[ "$machine_mem" -lt 65536 ]]; then
heap_size="$(("$machine_mem" / 2))m"
else
heap_size=32768m
fi
fi
debug "Setting '-Xmx${heap_size} -Xms${heap_size}' heap options..."
sed -r -i "s/-Xmx[0-9]+[mg]+/-Xmx${heap_size}/g" "${ELASTICSEARCH_CONFDIR}/jvm.options"
sed -r -i "s/-Xms[0-9]+[mg]+/-Xms${heap_size}/g" "${ELASTICSEARCH_CONFDIR}/jvm.options"
}
########################
# Migrate old Elasticsearch data
# Globals:
# ELASTICSEARCH_*
# Arguments:
# None
# Returns:
# None
#########################
migrate_old_data() {
warn "Persisted data follows old structure. Migrating to new one..."
warn "Custom configuration files won't be persisted any longer!"
local old_data_dir="${ELASTICSEARCH_DATADIR}/elasticsearch"
local old_custom_conf_file="${old_data_dir}/conf/elasticsearch_custom.yml"
local custom_conf_file="${ELASTICSEARCH_CONFDIR}/elasticsearch_custom.yml"
if [[ -f "$old_custom_conf_file" ]]; then
debug "Adding old custom configuration to user configuration"
echo "" >> "$custom_conf_file"
cat "$old_custom_conf_file" >> "$custom_conf_file"
fi
debug "Adapting data to new file structure"
find "${old_data_dir}/data" -maxdepth 1 -mindepth 1 -exec mv {} "$ELASTICSEARCH_DATADIR" \;
debug "Removing data that is not persisted anymore from persisted directory"
rm -rf "$old_data_dir" "${ELASTICSEARCH_DATADIR}/java"
}
########################
# Configure/initialize Elasticsearch
# Globals:
# ELASTICSEARCH_*
# Arguments:
# None
# Returns:
# None
#########################
elasticsearch_initialize() {
info "Configuring/Initializing Elasticsearch..."
# Persisted data from old versions
if ! is_dir_empty "$ELASTICSEARCH_DATADIR"; then
debug "Detected persisted data from previous deployments"
[[ -d "$ELASTICSEARCH_DATADIR/elasticsearch" ]] && [[ -f "$ELASTICSEARCH_DATADIR/elasticsearch/.initialized" ]] && migrate_old_data
fi
debug "Ensuring expected directories/files exist..."
for dir in "$ELASTICSEARCH_TMPDIR" "$ELASTICSEARCH_DATADIR" "$ELASTICSEARCH_LOGDIR" "$ELASTICSEARCH_BASEDIR/plugins" "$ELASTICSEARCH_BASEDIR/modules" "$ELASTICSEARCH_CONFDIR/scripts"; do
ensure_dir_exists "$dir"
am_i_root && chown "$ELASTICSEARCH_DAEMON_USER:$ELASTICSEARCH_DAEMON_GROUP" "$dir"
done
debug "Setting default configuration"
elasticsearch_conf_set http.port "$ELASTICSEARCH_PORT_NUMBER"
elasticsearch_conf_set path.data "$ELASTICSEARCH_DATADIR"
elasticsearch_conf_set transport.tcp.port "$ELASTICSEARCH_NODE_PORT_NUMBER"
elasticsearch_cluster_configuration
elasticsearch_configure_node_type
elasticsearch_set_heap_size
# User injected custom configuration
readonly custom_conf_file="$ELASTICSEARCH_CONFDIR/elasticsearch_custom.yml"
if [[ -f "$custom_conf_file" ]]; then
debug "Custom configuration detected. Injecting..."
echo "" >> "$ELASTICSEARCH_CONF_FILE"
cat "$custom_conf_file" >> "$ELASTICSEARCH_CONF_FILE"
fi
}
########################
# Install Elasticsearch plugins
# Globals:
# ELASTICSEARCH_PLUGINS
# Arguments:
# None
# Returns:
# None
#########################
elasticsearch_install_plugins() {
read -r -a plugins_list <<< "$(tr ',;' ' ' <<< "$ELASTICSEARCH_PLUGINS")"
debug "Installing plugins: ${plugins_list[*]}"
for plugin in "${plugins_list[@]}"; do
debug "Installing plugin: $plugin"
if [[ "${BITNAMI_DEBUG:-false}" = true ]]; then
elasticsearch-plugin install -b -v "$plugin"
else
elasticsearch-plugin install -b -v "$plugin" >/dev/null 2>&1
fi
done
}

View File

@ -1,14 +1,15 @@
#!/bin/bash
# shellcheck disable=SC1091
# Load libraries
. /libelasticsearch.sh
. /libfs.sh
# Load Elasticsearch env. variables
eval "$(elasticsearch_env)"
for dir in "$ELASTICSEARCH_TMPDIR" "$ELASTICSEARCH_DATADIR" "$ELASTICSEARCH_LOGDIR" "$ELASTICSEARCH_BASEDIR/plugins" "$ELASTICSEARCH_BASEDIR/modules" "$ELASTICSEARCH_CONFDIR/scripts"; do
for dir in "$ELASTICSEARCH_TMPDIR" "$ELASTICSEARCH_DATADIR" "$ELASTICSEARCH_LOGDIR" "${ELASTICSEARCH_BASEDIR}/plugins" "${ELASTICSEARCH_BASEDIR}/modules" "${ELASTICSEARCH_CONFDIR}/scripts"; do
ensure_dir_exists "$dir"
done
chmod -R g+rwX "$ELASTICSEARCH_CONFDIR" "$ELASTICSEARCH_TMPDIR" "$ELASTICSEARCH_DATADIR" "$ELASTICSEARCH_LOGDIR" "$ELASTICSEARCH_BASEDIR/plugins" "$ELASTICSEARCH_BASEDIR/modules"
ensure_user_exists "$ELASTICSEARCH_DAEMON_USER"
chmod -R g+rwX "$ELASTICSEARCH_CONFDIR" "$ELASTICSEARCH_TMPDIR" "$ELASTICSEARCH_DATADIR" "$ELASTICSEARCH_LOGDIR" "${ELASTICSEARCH_BASEDIR}/plugins" "${ELASTICSEARCH_BASEDIR}/modules"

View File

@ -4,20 +4,23 @@ set -o errexit
set -o nounset
set -o pipefail
#set -o xtrace
# shellcheck disable=SC1091
# Load libraries
. /libelasticsearch.sh
. /libos.sh
# Load Elasticsearch env. variables
eval "$(elasticsearch_env)"
DAEMON=elasticsearch
EXEC=$(which "$DAEMON")
ARGS="-p $ELASTICSEARCH_TMPDIR/elasticsearch.pid -Epath.data=$ELASTICSEARCH_DATADIR"
# Constants
EXEC=$(command -v elasticsearch)
ARGS=("-p" "$ELASTICSEARCH_TMPDIR/elasticsearch.pid" "-Epath.data=$ELASTICSEARCH_DATADIR")
export JAVA_HOME=/opt/bitnami/java
info "** Starting Elasticsearch **"
if am_i_root; then
exec gosu "$ELASTICSEARCH_DAEMON_USER" "$EXEC" $ARGS
exec gosu "$ELASTICSEARCH_DAEMON_USER" "$EXEC" "${ARGS[@]}"
else
exec "$EXEC" $ARGS
exec "$EXEC" "${ARGS[@]}"
fi

View File

@ -4,23 +4,27 @@ set -o errexit
set -o nounset
set -o pipefail
#set -o xtrace
# shellcheck disable=SC1091
# Load libraries
. /libos.sh
. /libfs.sh
. /libelasticsearch.sh
# Load Elasticsearch env. variables
eval "$(elasticsearch_env)"
# ensure elasticsearch env var settings are valid
# Ensure kernel settings are valid
elasticsearch_validate_kernel
# Ensure Elasticsearch env var settings are valid
elasticsearch_validate
# ensure elasticsearch is stopped when this script ends.
# Ensure Elasticsearch is stopped when this script ends
trap "elasticsearch_stop" EXIT
if am_i_root; then
ensure_user_exists "$ELASTICSEARCH_DAEMON_USER" "$ELASTICSEARCH_DAEMON_GROUP"
fi
# ensure elasticsearch is initialized
# Ensure 'daemon' user exists when running as 'root'
am_i_root && ensure_user_exists "$ELASTICSEARCH_DAEMON_USER" "$ELASTICSEARCH_DAEMON_GROUP"
# Ensure Elasticsearch is initialized
elasticsearch_initialize
# Install Elasticsearch plugins
if [[ -n "$ELASTICSEARCH_PLUGINS" ]]; then
elasticsearch_install_plugins
fi

View File

@ -50,7 +50,7 @@ Learn more about the Bitnami tagging policy and the difference between rolling t
* [`6-ol-7`, `6.4.2-ol-7-r33` (6/ol-7/Dockerfile)](https://github.com/bitnami/bitnami-docker-elasticsearch/blob/6.4.2-ol-7-r33/6/ol-7/Dockerfile)
* [`6-debian-9`, `6.4.2-debian-9-r20`, `6`, `6.4.2`, `6.4.2-r20`, `latest` (6/debian-9/Dockerfile)](https://github.com/bitnami/bitnami-docker-elasticsearch/blob/6.4.2-debian-9-r20/6/debian-9/Dockerfile)
* [`6-debian-9`, `6.4.2-debian-9-r21`, `6`, `6.4.2`, `6.4.2-r21`, `latest` (6/debian-9/Dockerfile)](https://github.com/bitnami/bitnami-docker-elasticsearch/blob/6.4.2-debian-9-r21/6/debian-9/Dockerfile)
* [`5-ol-7`, `5.6.12-ol-7-r29` (5/ol-7/Dockerfile)](https://github.com/bitnami/bitnami-docker-elasticsearch/blob/5.6.12-ol-7-r29/5/ol-7/Dockerfile)
* [`5-debian-9`, `5.6.12-debian-9-r22`, `5`, `5.6.12`, `5.6.12-r22` (5/debian-9/Dockerfile)](https://github.com/bitnami/bitnami-docker-elasticsearch/blob/5.6.12-debian-9-r22/5/debian-9/Dockerfile)

View File

@ -9,8 +9,8 @@ jobs:
LATEST_STABLE: "6"
DISTRIBUTIONS_LIST: "debian-9,ol-7"
IMAGE_NAME: elasticsearch
CHART_NAME: elasticsearch
CHART_REPO: https://github.com/bitnami/charts
DOCKER_PROJECT: bitnami
QUAY_PROJECT: bitnami
GCLOUD_PROJECT: bitnami-containers