Merge remote-tracking branch 'dakrone/dont-mkdir-data-with-comma'

This commit is contained in:
Lee Hinman 2016-05-17 13:56:59 -06:00
commit 4003d3f077
2 changed files with 24 additions and 1 deletions

View File

@ -117,7 +117,13 @@ case "$1" in
fi
# Prepare environment
mkdir -p "$LOG_DIR" "$DATA_DIR" && chown "$ES_USER":"$ES_GROUP" "$LOG_DIR" "$DATA_DIR"
# Check $DATA_DIR for a comma
if [ "${DATA_DIR#*,}" != "$DATA_DIR" ]; then
# $DATA_DIR contains a comma, so we should not mkdir it
mkdir -p "$LOG_DIR" && chown "$ES_USER":"$ES_GROUP" "$LOG_DIR"
else
mkdir -p "$LOG_DIR" "$DATA_DIR" && chown "$ES_USER":"$ES_GROUP" "$LOG_DIR" "$DATA_DIR"
fi
# Ensure that the PID_DIR exists (it is cleaned at OS startup time)
if [ -n "$PID_DIR" ] && [ ! -e "$PID_DIR" ]; then

View File

@ -117,6 +117,23 @@ setup() {
[ "$status" -eq 3 ] || [ "$status" -eq 4 ]
}
@test "[INIT.D] don't mkdir when it contains a comma" {
# Remove these just in case they exist beforehand
rm -rf /tmp/aoeu,/tmp/asdf
rm -rf /tmp/aoeu,
# set DATA_DIR to DATA_DIR=/tmp/aoeu,/tmp/asdf
sed -i 's/DATA_DIR=.*/DATA_DIR=\/tmp\/aoeu,\/tmp\/asdf/' /etc/init.d/elasticsearch
cat /etc/init.d/elasticsearch | grep "DATA_DIR"
service elasticsearch start
wait_for_elasticsearch_status
assert_file_not_exist /tmp/aoeu,/tmp/asdf
assert_file_not_exist /tmp/aoeu,
service elasticsearch stop
run service elasticsearch status
# precise returns 4, trusty 3
[ "$status" -eq 3 ] || [ "$status" -eq 4 ]
}
# Simulates the behavior of a system restart:
# the PID directory is deleted by the operating system
# but it should not block ES from starting