bitnami-containers/bitnami/elasticsearch/7/ol-7/rootfs/postunpack.sh

27 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
# shellcheck disable=SC1091
# Load libraries
. /libelasticsearch.sh
. /libfs.sh
# Load Elasticsearch environment variables
eval "$(elasticsearch_env)"
for dir in "$ELASTICSEARCH_TMPDIR" "$ELASTICSEARCH_DATADIR" "$ELASTICSEARCH_LOGDIR" "${ELASTICSEARCH_BASEDIR}/plugins" "${ELASTICSEARCH_BASEDIR}/modules" "${ELASTICSEARCH_CONFDIR}"; do
ensure_dir_exists "$dir"
chmod -R ug+rwX "$dir"
# `elasticsearch-plugin install` command complains about being unable to create the a plugin's directory
# even when having the proper permissions.
# The reason: the code is checking trying to check the permissions by consulting the parent directory owner,
# instead of checking if the ES user actually has writing permissions.
#
# As a workaround, we will ensure the container works (at least) with the non-root user 1001. However,
# until we can avoid this hack, we can't guarantee this container to work on K8s distributions
# where containers are exectued with non-privileged users with random user IDs.
#
# Issue reported at: https://github.com/bitnami/bitnami-docker-elasticsearch/issues/50
chown -R 1001:0 "$dir"
done