You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# When run for the first time, the original configuration will be backed up and all configuration entries will be set.
19
+
# When run again (re-configuration), the template configuration at the end if the script is executed again.
20
+
#
21
+
# Requires operatingSystemFunctions.sh
22
+
23
+
# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands)
24
+
set -o errexit -o pipefail
25
+
26
+
NEO4J_EDITION=${NEO4J_EDITION:-"community"}# Choose "community" or "enterprise"
27
+
NEO4J_VERSION=${NEO4J_VERSION:-"2026.01.4"}
28
+
29
+
DATA_DIRECTORY=${DATA_DIRECTORY:-"$(pwd -P )/data"}# Path where Neo4j writes its data to (outside tools dir)
30
+
RUNTIME_DIRECTORY=${RUNTIME_DIRECTORY:-"$(pwd -P )/runtime"}# Path where Neo4j puts runtime data to (e.g. logs) (outside tools dir)
31
+
TOOLS_DIRECTORY=${TOOLS_DIRECTORY:-"tools"}# Get the tools directory (defaults to "tools")
32
+
IMPORT_DIRECTORY=${IMPORT_DIRECTORY:-"$(pwd -P )/import"}# The name of the directory that is used to import data (e.g. CSV) files. Defaults to "import".
NEO4J_HTTP_PORT=${NEO4J_HTTP_PORT:-"7474"}# Neo4j HTTP API port for executing queries
36
+
NEO4J_HTTPS_PORT=${NEO4J_HTTPS_PORT:-"7473"}# Neo4j HTTPS port for encrypted querying
37
+
NEO4J_BOLT_PORT=${NEO4J_BOLT_PORT:-"7687"}# Neo4j's own "Bolt Protocol" port
38
+
39
+
NEO4J_CONFIG_TEMPLATE=${NEO4J_CONFIG_TEMPLATE:-"template-neo4j.conf"}# Name of the template file ("configuration" folder) for the Neo4j configuration. Defaults to "template-neo4j.conf".
40
+
41
+
## Get this "scripts" directory if not already set
42
+
# Even if $BASH_SOURCE is made for Bourne-like shells it is also supported by others and therefore here the preferred solution.
43
+
# CDPATH reduces the scope of the cd command to potentially prevent unintended directory changes.
44
+
# This way non-standard tools like readlink aren't needed.
45
+
SCRIPTS_DIR=${SCRIPTS_DIR:-$( CDPATH=. cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P )}# Repository directory containing the shell scripts
print "# This file had been configured with the configureNeo4j.sh script of code-graph-analysis-pipeline."
83
+
print "# Manual changes to this file might be overwritten when the script is executed again since the script is designed to update the configuration according to the template configuration."
84
+
print "# Please check the documentation of the configureNeo4j.sh script for more details."
local EYE_CATCHER_COMMENT_PREFIX="# The following configuration entries were taken from"
96
+
97
+
# Check if a template configuration had already been appended by looking for the eye-catcher comment.
98
+
# If it is already there, then delete the old template configuration including the eye-catcher and append the new one again to update it.
99
+
# This way this function is idempotent, the configuration is always up to date with the template and there are no duplicate entries.
100
+
if grep -q "^${EYE_CATCHER_COMMENT_PREFIX}""${NEO4J_CONFIG}";then
101
+
echo"${SCRIPT_NAME}: Deleting old configuration that had been appended from the template before since the eye-catcher comment was found. This ensures that there are no duplicate entries and that the configuration is up to date with the template."
102
+
sed -i.edit.backup "/^${EYE_CATCHER_COMMENT_PREFIX}/,/^# End of configuration from ${NEO4J_CONFIG_TEMPLATE}/d""${NEO4J_CONFIG}"
103
+
if grep -q '^$'"${NEO4J_CONFIG}";then
104
+
sed -i.edit.backup '$d'"${NEO4J_CONFIG}"# Delete the last line of the config if it is an empty line
105
+
fi
106
+
rm -f "${NEO4J_CONFIG}.edit.backup"# The backup is created even if not needed to be compatible with both GNU sed and BSD sed (e.g. on
107
+
fi
108
+
109
+
# Append first an eye-catcher comment to the configuration file to indicate that the configuration is script-managed
110
+
# and that manual changes might be overwritten.
111
+
{
112
+
echo""
113
+
echo"${EYE_CATCHER_COMMENT_PREFIX} '${NEO4J_CONFIG_TEMPLATE}' by the script ${SCRIPT_NAME}."
114
+
echo"# WARNING: Manual changes below this line might be overwritten when the script is executed again."
fail "Requires variable TOOLS_DIRECTORY to be set. If it is the current directory, then use a dot to reflect that."
123
+
fi
124
+
if [ !-d"${TOOLS_DIRECTORY}" ];then
125
+
fail "Tools directory <${TOOLS_DIRECTORY}> does not exist. Please install Neo4j first by running the setupNeo4j.sh script which will create the tools directory if necessary."
126
+
fi
127
+
128
+
# Check if SHARED_DOWNLOADS_DIRECTORY variable is set
129
+
if [ -z"${SHARED_DOWNLOADS_DIRECTORY}" ];then
130
+
fail "Requires variable SHARED_DOWNLOADS_DIRECTORY to be set. If it is the current directory, then use a dot to reflect that."
131
+
fi
132
+
if [ !-d"${SHARED_DOWNLOADS_DIRECTORY}" ];then
133
+
fail "Shared downloads directory <${SHARED_DOWNLOADS_DIRECTORY}> does not exist. Please install Neo4j first by running the setupNeo4j.sh script which will create the shared downloads directory if necessary."
134
+
fi
135
+
136
+
# Fail if Neo4j hadn't been downloaded yet
137
+
if [ !-d"${NEO4J_INSTALLATION_DIRECTORY}" ] ;then
138
+
fail "${NEO4J_INSTALLATION_NAME} is not installed into ${TOOLS_DIRECTORY} yet. Please run the setupNeo4j.sh script first to download and install Neo4j."
139
+
fi
140
+
141
+
if [ !-f"${NEO4J_CONFIG_TEMPLATE_PATH}" ];then
142
+
fail "Configuration template file ${NEO4J_CONFIG_TEMPLATE} does not exist in the scripts/configuration folder. Please make sure it exists and is correctly named:\n${NEO4J_CONFIG_TEMPLATE_PATH}"
143
+
fi
144
+
145
+
# Create a backup of the original configuration file before any modification in case there is none yet.
0 commit comments