Skip to content

Commit

Permalink
changed default neo4j version to latest v3.3.3
Browse files Browse the repository at this point in the history
create is now using instances folder as tmp to allow setfacl or other permissions to have an effect on new instances
changed checks to be done before any download is triggered to save time and bandwidth
changed tests accordingly
  • Loading branch information
ogmueller committed Feb 22, 2018
1 parent 519a173 commit 0b3a996
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
36 changes: 18 additions & 18 deletions ineo
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ VERSION=1.1.0

DEFAULT_HOME="${HOME}/.ineo"

DEFAULT_VERSION='3.3.1'
DEFAULT_VERSION='3.3.3'

DEFAULT_PORT='7474'

Expand Down Expand Up @@ -464,6 +464,14 @@ function create {
exit 1
fi

# If directory for the instance exists then a message suggesting run or
# install with the option -f is showed
if [[ -d "${INEO_HOME}/instances/${instance_name}" ]] && ! ${force_install} ; then
printf "\n ${PURPLE}Error -> A directory for the instance ${BOLD}${instance_name}${PURPLE} already exists\n"
printf "\n ${NF}Maybe the instance already was created or try run the command ${UNDERLINE}install${NF} with the -f option to force the installation\n\n"
exit 1
fi

# Bolt port only works with Neo4j version 3.0 or higher
if [[ "${version%%.*}" -lt 3 && "${bolt_port}" ]]; then
printf "\n ${PURPLE}Error -> Bolt port only works on Neo4j 3.0 or higher\n"
Expand All @@ -483,43 +491,35 @@ function create {
local tar_name="neo4j-${edition}-${version}-unix.tar.gz"

# Donwload and create tar if doesn't exists
if ! [ -f ${INEO_HOME}/neo4j/${tar_name} ] || ${force_download}; then
curl -o ${TEMP_DIR}/${tar_name} ${NEO4J_HOSTNAME}/${tar_name}
if [[ ! -f "${INEO_HOME}/neo4j/${tar_name}" || ${force_download} ]]; then
curl -o "${TEMP_DIR}/${tar_name}" "${NEO4J_HOSTNAME}/${tar_name}"

mv ${TEMP_DIR}/${tar_name} ${INEO_HOME}/neo4j/${tar_name}
mv "${TEMP_DIR}/${tar_name}" "${INEO_HOME}/neo4j/${tar_name}"
fi

# Create tmp dir to extract
mkdir -p ${TEMP_DIR}/${version}
mkdir -p "${INEO_HOME}/instances/.${instance_name}"
# if is not extracted then the tar maybe is not good, so a message suggesting
# to use -d option is showed
if ! tar -xzf ${INEO_HOME}/neo4j/${tar_name} \
-C ${TEMP_DIR}/${version} &> /dev/null; then
if ! tar --strip 1 -xzf "${INEO_HOME}/neo4j/${tar_name}" \
-C "${INEO_HOME}/instances/.${instance_name}" &> /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
fi

# If directory for the instance exists then a message suggesting run or
# install with the option -f is showed
if [[ -d "${INEO_HOME}/instances/${instance_name}" ]] && ! ${force_install} ; then
printf "\n ${PURPLE}Error -> A directory for the instance ${BOLD}${instance_name}${PURPLE} already exists\n"
printf "\n ${NF}Maybe the instance already was created or try run the command ${UNDERLINE}install${NF} with the -f option to force the installation\n\n"
exit 1
fi

if ${force_install} ; then
rm -rf "${INEO_HOME}/instances/${instance_name}"
fi

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

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

# Finnaly move the instance for installation
mv ${TEMP_DIR}/${version}/neo4j-${edition}-${version} ${INEO_HOME}/instances/${instance_name}
mv "${INEO_HOME}/instances/.${instance_name}" "${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
6 changes: 1 addition & 5 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function assert_run_pid {
local pid=$1
# we need to wait some seconds, because on fast computers the pid will exists
# even though neo4j terminates due to a configuration error
sleep 3
sleep 3
assert_raises "test $(ps -p $pid -o pid=)" 0
}

Expand Down Expand Up @@ -877,10 +877,6 @@ CreateAnInstanceOnAExistingDirectoryAndTryAgainWithFOption() {
${NF}Maybe the instance already was created or try run the command ${UNDERLINE}install${NF} with the -f option to force the installation
"

# Ensure the bad tar version of neo4j was downloaded
assert_raises \
"test -f $(pwd)/ineo_for_test/neo4j/neo4j-community-$LAST_VERSION-unix.tar.gz" 0

# Ensure the instance directory is empty yet
assert_raises "test $(ls -A ineo_for_test/instances/twitter)" 1

Expand Down

0 comments on commit 0b3a996

Please sign in to comment.