Skip to content

Commit d34ad3e

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

File tree

3 files changed

+33
-21
lines changed

3 files changed

+33
-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: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,20 @@ 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+
50+
# TODO For Windows the local service needs to be installed to start the local server the same way as for Linux/Mac.
51+
# Notice: This needs admin rights that need to be confirmed in a dialog box.
52+
# NEO4J_HOME=${NEO4J_DIR} | "${NEO4J_BIN}/neo4j${scriptExtension}" windows-service install
53+
# A much better solution for that is using the console option which needs a separate terminal
54+
#NEO4J_HOME=${NEO4J_DIR} | "${NEO4J_BIN}/neo4j${scriptExtension}" console
55+
4456
# 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)"
57+
neo4jStatus="$( NEO4J_HOME=${NEO4J_DIR} | ${NEO4J_BIN}/neo4j${scriptExtension} status 2>&1 || true)"
4658
neo4jNotRunning=$(echo "$neo4jStatus" | grep "not running" || true)
4759
if [ -n "${neo4jNotRunning}" ]; then
4860
echo "startNeo4j: Starting neo4j-${NEO4J_EDITION}-${NEO4J_VERSION} in ${NEO4J_DIR}"
@@ -57,14 +69,14 @@ if [ -n "${neo4jNotRunning}" ]; then
5769
fi
5870

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

6274
# Wait some time for the start of the database
6375
echo "${WAIT_TIMES}" | tr ' ' '\n' | while read waitTime; do
6476
echo "startNeo4j: Waiting for ${waitTime} second(s)"
6577
sleep ${waitTime}
6678

67-
neo4jStatus="$( NEO4J_HOME=${NEO4J_DIR} ${NEO4J_BIN}/neo4j status 2>&1 || true)"
79+
neo4jStatus="$( NEO4J_HOME=${NEO4J_DIR} | ${NEO4J_BIN}/neo4j${scriptExtension} status 2>&1 || true)"
6880
neo4jNotRunning=$(echo "$neo4jStatus" | grep "not running" || true)
6981
if [ -z "${neo4jNotRunning}" ]; then
7082
echo "startNeo4j: Successfully started neo4j-${NEO4J_EDITION}-${NEO4J_VERSION}"
@@ -76,7 +88,7 @@ else
7688
fi
7789

7890
# 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)"
91+
neo4jStatus="$( NEO4J_HOME=${NEO4J_DIR} | ${NEO4J_BIN}/neo4j${scriptExtension} status 2>&1 || true)"
8092
neo4jNotRunning=$(echo "$neo4jStatus" | grep "not running" || true)
8193
if [ -n "${neo4jNotRunning}" ]; then
8294
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)