Skip to content

Commit eefcc55

Browse files
committed
fixup! Support windows tested in git bash
1 parent 5d29ff1 commit eefcc55

File tree

3 files changed

+23
-36
lines changed

3 files changed

+23
-36
lines changed

scripts/setupNeo4j.sh

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# Note: The environment variable NEO4J_INITIAL_PASSWORD needs to be set.
66

7-
# Requires download.sh,setupNeo4jInitialPassword.sh
7+
# Requires download.sh,setupNeo4jInitialPassword.sh,operatingSystemFunctions.sh
88

99
# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands)
1010
set -eo pipefail
@@ -68,22 +68,16 @@ if [ -z "${NEO4J_INITIAL_PASSWORD}" ]; then
6868
exit 1
6969
fi
7070

71+
# Include operation system function to for example detect Windows.
72+
source "${SCRIPTS_DIR}/operatingSystemFunctions.sh"
73+
7174
# Download and extract Neo4j
7275
if [ ! -d "${NEO4J_INSTALLATION_DIRECTORY}" ] ; then
7376

74-
isWindows=false
75-
if [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then
76-
isWindows=true
77-
fi
78-
echo "setupNeo4j: Detected isWindows=${isWindows} for operating system type ${OSTYPE}"
79-
80-
neo4jInstallationSystemPostfix="unix.tar.gz"
81-
if [[ "${isWindows}" = true ]]; then
82-
neo4jInstallationSystemPostfix="windows.zip"
83-
fi
84-
echo "setupNeo4j: Using ${neo4jInstallationSystemPostfix} for operating system type ${OSTYPE}"
85-
77+
neo4jInstallationSystemPostfix=$(ifWindows "windows.zip" "unix.tar.gz")
8678
neo4jDownloadArchiveFileName="${NEO4J_INSTALLATION_NAME}-${neo4jInstallationSystemPostfix}"
79+
echo "setupNeo4j: Using Neo4j distribution ${neo4jDownloadArchiveFileName}"
80+
8781
source "${SCRIPTS_DIR}/download.sh" --url "https://dist.neo4j.org/${neo4jDownloadArchiveFileName}" || exit 1
8882

8983
if [[ ${neo4jInstallationSystemPostfix} == "unix.tar.gz" ]]; then
@@ -105,7 +99,7 @@ if [ ! -d "${NEO4J_INSTALLATION_DIRECTORY}" ] ; then
10599
echo "setupNeo4j: Configuring dynamic settings (data directories, ports, ...)"
106100

107101
## TODO find a solution for Windows e.g. converting the paths to Windows style
108-
if [[ "${isWindows}" = false ]]; then
102+
if ! isWindows; then
109103
if [[ "$NEO4J_MAJOR_VERSION_NUMBER" -ge 5 ]]; then
110104
echo "setupNeo4j: Neo4j v5 or higher detected"
111105
{

scripts/startNeo4j.sh

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Note: Does nothing if the database is already running.
66
# Note: It requires Neo4j to be installed in the TOOLS_DIRECTORY.
77

8-
# Requires waitForNeo4jHttp.sh
8+
# Requires waitForNeo4jHttp.sh,operatingSystemFunctions.sh
99

1010
# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands)
1111
set -eo pipefail
@@ -43,28 +43,22 @@ else
4343
exit 1
4444
fi
4545

46-
isWindows=false
47-
if [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then
48-
isWindows=true
49-
fi
50-
echo "startNeo4j: Detected isWindows=${isWindows} for operating system type ${OSTYPE}"
46+
# Include operation system function to for example detect Windows.
47+
source "${SCRIPTS_DIR}/operatingSystemFunctions.sh"
5148

52-
scriptExtension=""
53-
if [[ "${isWindows}" = true ]]; then
54-
scriptExtension=".bat"
55-
echo "startNeo4j: Using scriptExtension ${scriptExtension} for Windows."
56-
fi
49+
scriptExtension=$(ifWindows ".bat" "")
50+
echo "startNeo4j: Using scriptExtension ${scriptExtension} for Windows."
5751

5852
# Include functions to check or wait for the database to be ready
5953
source "${SCRIPTS_DIR}/waitForNeo4jHttpFunctions.sh"
6054

6155
# Check if Neo4j is stopped (not running) using a temporary NEO4J_HOME environment variable that points to the current installation
6256
isDatabaseReady=$(isDatabaseQueryable)
6357
if [[ ${isDatabaseReady} == "false" ]]; then
64-
echo "startNeo4j: Starting neo4j-${NEO4J_EDITION}-${NEO4J_VERSION} in ${NEO4J_DIR} with isWindows=${isWindows}"
58+
echo "startNeo4j: Starting neo4j-${NEO4J_EDITION}-${NEO4J_VERSION} in ${NEO4J_DIR}"
6559

6660
# Check if there is already a process that listens to the Neo4j HTTP port
67-
if [[ "${isWindows}" = true ]]; then
61+
if isWindows; then
6862
echo "startNeo4j: Skipping detection of processes listening to port ${NEO4J_HTTP_PORT} on Windows"
6963
else
7064
port_listener_process_id=$( lsof -t -i:"${NEO4J_HTTP_PORT}" -sTCP:LISTEN || true )
@@ -77,7 +71,7 @@ if [[ ${isDatabaseReady} == "false" ]]; then
7771
fi
7872

7973
# Start Neo4j using a temporary NEO4J_HOME environment variable that points to the current installation
80-
if [[ "${isWindows}" = true ]]; then
74+
if isWindows; then
8175
neo4jStartCommand="${NEO4J_BIN_WINDOWS}\neo4j${scriptExtension} console --verbose"
8276
# On Windows it is necessary to take the absolute full qualified path to Neo4j for the environment variable NEO4J_HOME.
8377
# It also works without any environment variable but this would likely lead to ambiguity problems when there are multiple Neo4j instances installed.

scripts/stopNeo4j.sh

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
# Note: Does nothing if the database is already stopped.
66

7+
# Requires waitForNeo4jHttp.sh,operatingSystemFunctions.sh
8+
79
# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands)
810
set -eo pipefail
911

@@ -37,11 +39,8 @@ else
3739
exit 1
3840
fi
3941

40-
isWindows=false
41-
if [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then
42-
isWindows=true
43-
fi
44-
echo "stopNeo4j: Detected isWindows=${isWindows} for operating system type ${OSTYPE}"
42+
# Include operation system function to for example detect Windows.
43+
source "${SCRIPTS_DIR}/operatingSystemFunctions.sh"
4544

4645
# Include functions to check or wait for the database to be ready
4746
source "${SCRIPTS_DIR}/waitForNeo4jHttpFunctions.sh"
@@ -52,7 +51,7 @@ if [[ ${isDatabaseReady} == "false" ]]; then
5251
echo "stopNeo4j: neo4j-${NEO4J_EDITION}-${NEO4J_VERSION} already stopped"
5352
exit 0
5453
else
55-
if [[ "${isWindows}" = true ]]; then
54+
if isWindows; then
5655
echo "stopNeo4j: IMPORTANT: Please close the console window manually where neo4j-${NEO4J_EDITION}-${NEO4J_VERSION} is running on Windows."
5756
else
5857
# Stop Neo4j using a temporary NEO4J_HOME environment variable that points to the current installation
@@ -65,14 +64,14 @@ isDatabaseReady=$(isDatabaseQueryable)
6564
if [[ ${isDatabaseReady} == "false" ]]; then
6665
echo "stopNeo4j: Successfully stopped neo4j-${NEO4J_EDITION}-${NEO4J_VERSION}"
6766
else
68-
if [[ "${isWindows}" = false ]]; then
67+
if ! isWindows; then
6968
echo "stopNeo4j: neo4j-${NEO4J_EDITION}-${NEO4J_VERSION} still running. Something went wrong. Details see 'NEO4J_HOME=${NEO4J_DIR} ${NEO4J_BIN}/neo4j${scriptExtension} status'."
7069
exit 1
7170
fi
7271
fi
7372

7473
# Check if there are still processes running that listen to the Neo4j HTTP port
75-
if [[ "${isWindows}" = true ]]; then
74+
if isWindows; then
7675
echo "stopNeo4j: Skipping detection of processes listening to port ${NEO4J_HTTP_PORT} on Windows"
7776
else
7877
port_listener_process_id=$( lsof -t -i:"${NEO4J_HTTP_PORT}" -sTCP:LISTEN || true )

0 commit comments

Comments
 (0)