@@ -22,8 +22,8 @@ set -xe
2222set -o pipefail
2323
2424# Get a script directory, same as by $(dirname $0)
25- # script_dir=${0%/*}
26- # absolute_script_dir=$(cd "${script_dir}" && pwd)
25+ script_dir=${0%/* }
26+ absolute_script_dir=$( cd " ${script_dir} " && pwd)
2727# work_dir=${1:-${absolute_script_dir}/build} # $1 with the default
2828# if [[ ! -d "${work_dir}" ]]; then
2929# mkdir "${work_dir}"
@@ -32,10 +32,10 @@ set -o pipefail
3232# cd "${work_dir}"
3333echo -e " \n## Running under ${USER} @${HOSTNAME} at ${PWD} ##\n"
3434
35- # if ! which cypher-shell >/dev/null; then
36- # echo "Please install Neo4j"
37- # exit 1
38- # fi
35+ if ! which cypher-shell > /dev/null; then
36+ echo " Please install Neo4j"
37+ exit 1
38+ fi
3939
4040nodes_file=" $1 "
4141edges_file=" $2 "
@@ -63,22 +63,9 @@ set +x
6363# `java.io.FileNotFoundException: import.report (Permission denied)` error
6464echo " $3 " | sudo --stdin -u neo4j bash -c " set -xe
6565 echo 'Loading data into ${db_name} ...'
66- neo4j-admin import --nodes:Publication '${nodes_file} ' --relationships:CITES '${edges_file} ' --database=" ${db_name} "
67- sed --in-place --expression='s/dbms.active_database=.*/dbms.active_database=${db_name} /' /etc/neo4j/neo4j.conf"
68-
69- echo " Restarting Neo4j with a new active database ..."
70- echo " $3 " | sudo --stdin systemctl restart neo4j
71-
72- declare -i time_limit_s=30
73- echo " Waiting for the service to become active up to ${time_limit_s} seconds ..."
74- # Ping Neo4j. Even if a service is active it might not be responding yet.
75- while ! cypher-shell " CALL dbms.components()" 2> /dev/null; do
76- if (( time_limit_s-- == 0 )) ; then
77- echo " ERROR: Neo4j failed to start." >&2
78- exit 2
79- fi
80- sleep 1
81- done
66+ neo4j-admin import --nodes:Publication '${nodes_file} ' --relationships:CITES '${edges_file} ' --database='${db_name} '"
67+
68+ ${absolute_script_dir} /neo4j_switch_db.sh " ${db_name} " " $3 "
8269set -x
8370# endregion
8471
0 commit comments