Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to catch cases of incorrect datadir ownership #74

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions cmd/elastic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,26 @@ set -e;

function elastic_schema_drop(){ compose_run 'schema' node scripts/drop_index "$@" || true; }
function elastic_schema_create(){ compose_run 'schema' ./bin/create_index; }

# perform pre-start checks and start the elasticsearch container
function elastic_start(){
mkdir -p $DATA_DIR/elasticsearch
# attemp to set proper permissions if running as root
chown $DOCKER_USER $DATA_DIR/elasticsearch 2>/dev/null || true

# record the owner of the Elasticsearch directory
elasticsearch_owner_uid=$($CMD_STAT --format '%u' $DATA_DIR/elasticsearch)

# grab just the first part of the $DOCKER_USER variable which may have format uid:gid (or just uid)
desired_owner_uid=(${DOCKER_USER//:/ })

# check permissions, and if $DOCKER_USER cannot read the data dir, quit with error
if [[ "$desired_owner_uid" != "$elasticsearch_owner_uid" ]]; then
cmd="sudo chown $DOCKER_USER $DATA_DIR/elasticsearch"
echo "User $DOCKER_USER cannot access elasticsearch directory at $DATA_DIR"
echo "attempting to fix permissins by running '$cmd'. You may be asked for your password."
$cmd
fi
compose_exec up -d elasticsearch
}

Expand Down
2 changes: 2 additions & 0 deletions pelias
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ set -e
# compatible with the linux tools. Force OSX users to install the GNU
# compatible versions (prefixed with 'g', such as 'greadlink', 'gsed' etc.).
export CMD_READLINK='readlink'
export CMD_STAT='stat'
if [[ "$OSTYPE" == "darwin"* ]]; then
if [ -x "$(command -v greadlink)" ]; then
CMD_READLINK='greadlink';
CMD_STAT='gstat';
else
2>&1 echo 'OSX: you must install the gnu standard tooling using:'
2>&1 echo 'brew install coreutils'
Expand Down