Skip to content

Commit

Permalink
added temporary instance creation dir to trap, so it will be cleared …
Browse files Browse the repository at this point in the history
…even on an interaptive event
  • Loading branch information
ogmueller committed Aug 9, 2018
1 parent 3892944 commit 2cabde1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions ineo
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ INEO_HOSTNAME="${INEO_HOSTNAME:-http://ineo.cohesivestack.com}"
LOCK_DIR='/tmp/ineo.neo4j.instances.lock'

TEMP_DIR="/tmp/$$.ineo"
INSTANCE_TEMP_DIR="${INEO_HOME}/instances/.tmp"

SED_CMD="sed -i''"

Expand Down Expand Up @@ -498,11 +499,11 @@ function create {
fi

# Create tmp dir to extract
mkdir -p "${INEO_HOME}/instances/.${instance_name}"
mkdir -p "${INSTANCE_TEMP_DIR}"
# if is not extracted then the tar maybe is not good, so a message suggesting
# to use -d option is showed
if ! tar --strip 1 -xzf "${INEO_HOME}/neo4j/${tar_name}" \
-C "${INEO_HOME}/instances/.${instance_name}" &> /dev/null; then
-C "${INSTANCE_TEMP_DIR}" &> /dev/null; then
printf "\n ${PURPLE}Error -> The tar file ${BOLD}${tar_name}${PURPLE} can't be extracted\n"
printf "\n ${NF}Try run the command ${UNDERLINE}create${NF} with the -d option to download the tar file again\n\n"
exit 1
Expand All @@ -513,13 +514,13 @@ function create {
fi

# Create a hidden file with the version used in this installation
echo "${version}" > "${INEO_HOME}/instances/.${instance_name}/.version"
echo "${version}" > "${INSTANCE_TEMP_DIR}/.version"

# Create a hidden file with the edition used in this installation
echo "${edition}" > "${INEO_HOME}/instances/.${instance_name}/.edition"
echo "${edition}" > "${INSTANCE_TEMP_DIR}/.edition"

# Finnaly move the instance for installation
mv "${INEO_HOME}/instances/.${instance_name}" "${INEO_HOME}/instances/${instance_name}"
mv "${INSTANCE_TEMP_DIR}" "${INEO_HOME}/instances/${instance_name}"

# If https or bolt port is not configured, then set them incrementally
https_port=${https_port:-$((${port} + 1))}
Expand Down Expand Up @@ -1533,7 +1534,7 @@ if [[ ! "${COMMAND}" == "UPDATE_SCRIPT_BATCH" ]]; then
exit 1
fi

trap "rmdir \"${LOCK_DIR}\"; rm -rf \"${TEMP_DIR}\"" EXIT
trap "rmdir \"${LOCK_DIR}\"; rm -rf \"${TEMP_DIR}\"; rm -rf \"${INSTANCE_TEMP_DIR}\"" EXIT
fi

# ==============================================================================
Expand Down

0 comments on commit 2cabde1

Please sign in to comment.