Skip to content

Commit b4d77a4

Browse files
committed
fixup! Support windows tested in git bash
1 parent 7fa05d9 commit b4d77a4

File tree

3 files changed

+27
-21
lines changed

3 files changed

+27
-21
lines changed

scripts/setupNeo4jInitialPassword.sh

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,31 +34,23 @@ echo "setupNeo4jInitialPassword: Using ${NEO4J_INSTALLATION_DIRECTORY} as NEO4J_
3434
NEO4J_MAJOR_VERSION_NUMBER=$(echo "$NEO4J_VERSION" | cut -d'.' -f1)
3535
echo "setupNeo4jInitialPassword: Neo4j version ${NEO4J_MAJOR_VERSION_NUMBER} detected"
3636

37-
isWindows=false
37+
scriptExtension=""
3838
if [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then
39-
isWindows=true
39+
scriptExtension=".bat"
4040
fi
41-
echo "setupNeo4jInitialPassword: Detected isWindows=${isWindows} for operating system type ${OSTYPE}"
41+
echo "setupNeo4jInitialPassword: Using scriptExtension ${scriptExtension} for operating system type ${OSTYPE}"
4242

4343
# Check if the first component is greater than or equal to 5
4444
if [[ "$NEO4J_MAJOR_VERSION_NUMBER" -ge 5 ]]; then
4545
echo "setupNeo4jInitialPassword: Neo4j v5 or higher used"
4646
# Neo4j version < 5
4747
# Set the initial password using a temporary NEO4J_HOME environment variable pointing to the current setup
48-
if [ "${isWindows}" = true ] ; then
49-
NEO4J_HOME="${NEO4J_INSTALLATION_DIRECTORY}" | "${NEO4J_INSTALLATION_DIRECTORY}/bin/neo4j-admin.bat" dbms set-initial-password "${NEO4J_INITIAL_PASSWORD}"
50-
else
51-
NEO4J_HOME="${NEO4J_INSTALLATION_DIRECTORY}" | "${NEO4J_INSTALLATION_DIRECTORY}/bin/neo4j-admin" dbms set-initial-password "${NEO4J_INITIAL_PASSWORD}"
52-
fi
48+
NEO4J_HOME="${NEO4J_INSTALLATION_DIRECTORY}" | "${NEO4J_INSTALLATION_DIRECTORY}/bin/neo4j-admin${scriptExtension}" dbms set-initial-password "${NEO4J_INITIAL_PASSWORD}"
5349
else
5450
echo "setupNeo4jInitialPassword: Neo4j v4 or lower used"
5551
# Neo4j version >= 5
5652
# Set the initial password using a temporary NEO4J_HOME environment variable pointing to the current setup
57-
if [ "${isWindows}" = true ] ; then
58-
NEO4J_HOME="${NEO4J_INSTALLATION_DIRECTORY}" | "${NEO4J_INSTALLATION_DIRECTORY}/bin/neo4j-admin.bat" set-initial-password "${NEO4J_INITIAL_PASSWORD}"
59-
else
60-
NEO4J_HOME="${NEO4J_INSTALLATION_DIRECTORY}" | "${NEO4J_INSTALLATION_DIRECTORY}/bin/neo4j-admin" set-initial-password "${NEO4J_INITIAL_PASSWORD}"
61-
fi
53+
NEO4J_HOME="${NEO4J_INSTALLATION_DIRECTORY}" | "${NEO4J_INSTALLATION_DIRECTORY}/bin/neo4j-admin${scriptExtension}" set-initial-password "${NEO4J_INITIAL_PASSWORD}"
6254
fi
6355

6456
echo "setupNeo4jInitialPassword: Initial password set sucessfully"

scripts/startNeo4j.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,14 @@ else
4141
exit 1
4242
fi
4343

44+
scriptExtension=""
45+
if [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then
46+
scriptExtension=".bat"
47+
fi
48+
echo "setupNeo4jInitialPassword: Using scriptExtension ${scriptExtension} for operating system type ${OSTYPE}"
49+
4450
# Check if Neo4j is stopped (not running) using a temporary NEO4J_HOME environment variable that points to the current installation
45-
neo4jStatus="$( NEO4J_HOME=${NEO4J_DIR} ${NEO4J_BIN}/neo4j status 2>&1 || true)"
51+
neo4jStatus="$( NEO4J_HOME=${NEO4J_DIR} | ${NEO4J_BIN}/neo4j${scriptExtension} status 2>&1 || true)"
4652
neo4jNotRunning=$(echo "$neo4jStatus" | grep "not running" || true)
4753
if [ -n "${neo4jNotRunning}" ]; then
4854
echo "startNeo4j: Starting neo4j-${NEO4J_EDITION}-${NEO4J_VERSION} in ${NEO4J_DIR}"
@@ -57,14 +63,14 @@ if [ -n "${neo4jNotRunning}" ]; then
5763
fi
5864

5965
# Start Neo4j using a temporary NEO4J_HOME environment variable that points to the current installation
60-
NEO4J_HOME=${NEO4J_DIR} ${NEO4J_BIN}/neo4j start
66+
NEO4J_HOME=${NEO4J_DIR} | ${NEO4J_BIN}/neo4j${scriptExtension} start --verbose
6167

6268
# Wait some time for the start of the database
6369
echo "${WAIT_TIMES}" | tr ' ' '\n' | while read waitTime; do
6470
echo "startNeo4j: Waiting for ${waitTime} second(s)"
6571
sleep ${waitTime}
6672

67-
neo4jStatus="$( NEO4J_HOME=${NEO4J_DIR} ${NEO4J_BIN}/neo4j status 2>&1 || true)"
73+
neo4jStatus="$( NEO4J_HOME=${NEO4J_DIR} | ${NEO4J_BIN}/neo4j${scriptExtension} status 2>&1 || true)"
6874
neo4jNotRunning=$(echo "$neo4jStatus" | grep "not running" || true)
6975
if [ -z "${neo4jNotRunning}" ]; then
7076
echo "startNeo4j: Successfully started neo4j-${NEO4J_EDITION}-${NEO4J_VERSION}"
@@ -76,7 +82,7 @@ else
7682
fi
7783

7884
# Check if Neo4j is still not running using a temporary NEO4J_HOME environment variable that points to the current installation
79-
neo4jStatus="$( NEO4J_HOME=${NEO4J_DIR} ${NEO4J_BIN}/neo4j status 2>&1 || true)"
85+
neo4jStatus="$( NEO4J_HOME=${NEO4J_DIR} | ${NEO4J_BIN}/neo4j${scriptExtension} status 2>&1 || true)"
8086
neo4jNotRunning=$(echo "$neo4jStatus" | grep "not running" || true)
8187
if [ -n "${neo4jNotRunning}" ]; then
8288
echo "startNeo4j: neo4j-${NEO4J_EDITION}-${NEO4J_VERSION} still not running. Something went wrong. Details see 'NEO4J_HOME=${NEO4J_DIR} ${NEO4J_BIN}/neo4j status'."

scripts/stopNeo4j.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,30 @@ else
3030
exit 1
3131
fi
3232

33+
scriptExtension=""
34+
if [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then
35+
scriptExtension=".bat"
36+
fi
37+
echo "setupNeo4jInitialPassword: Using scriptExtension ${scriptExtension} for operating system type ${OSTYPE}"
38+
3339
# Check if Neo4j is stopped (not running) using a temporary NEO4J_HOME environment variable that points to the current installation
34-
if NEO4J_HOME=${NEO4J_DIR} ${NEO4J_BIN}/neo4j status 2>&1 | grep -q "not running" ; then
40+
neo4jStatus="$( NEO4J_HOME=${NEO4J_DIR} | ${NEO4J_BIN}/neo4j${scriptExtension} status 2>&1 || true)"
41+
neo4jNotRunning=$(echo "$neo4jStatus" | grep "not running" || true)
42+
if [ -n "${neo4jNotRunning}" ]; then
3543
echo "stopNeo4j: neo4j-${NEO4J_EDITION}-${NEO4J_VERSION} aleady stopped"
3644
exit 0
3745
else
3846
# Stop Neo4j using a temporary NEO4J_HOME environment variable that points to the current installation
39-
NEO4J_HOME=${NEO4J_DIR} ${NEO4J_BIN}/neo4j stop
47+
NEO4J_HOME=${NEO4J_DIR} | ${NEO4J_BIN}/neo4j${scriptExtension} stop
4048
fi
4149

4250
# Check if Neo4j is still not running using a temporary NEO4J_HOME environment variable that points to the current installation
43-
neo4jStatus="$( NEO4J_HOME=${NEO4J_DIR} ${NEO4J_BIN}/neo4j status 2>&1 || true)"
51+
neo4jStatus="$( NEO4J_HOME=${NEO4J_DIR} | ${NEO4J_BIN}/neo4j${scriptExtension} status 2>&1 || true)"
4452
neo4jNotRunning=$(echo "$neo4jStatus" | grep "not running" || true)
4553
if [ -n "${neo4jNotRunning}" ]; then
4654
echo "stopNeo4j: Successfully stopped neo4j-${NEO4J_EDITION}-${NEO4J_VERSION}"
4755
else
48-
echo "stopNeo4j: neo4j-${NEO4J_EDITION}-${NEO4J_VERSION} still running. Something went wrong. Details see 'NEO4J_HOME=${NEO4J_DIR} ${NEO4J_BIN}/neo4j status'."
56+
echo "stopNeo4j: neo4j-${NEO4J_EDITION}-${NEO4J_VERSION} still running. Something went wrong. Details see 'NEO4J_HOME=${NEO4J_DIR} ${NEO4J_BIN}/neo4j${scriptExtension} status'."
4957
exit 1
5058
fi
5159

0 commit comments

Comments
 (0)