From 79c9d614973c88c3dbe4875932c9471971f6e740 Mon Sep 17 00:00:00 2001 From: DiCanio Date: Thu, 15 Apr 2021 16:48:27 +0200 Subject: [PATCH] Always Set Project Dir as Working Dir Replaces any calls to pwd with a routine that sets baseDir to the location of any affected invoked script. This change avoids changes to directories outside of this project when its scripts are invoked from outside of the project directory. Currently only follows a single symlink since MacOS is missing the -f flag necessary for following multiple links. --- down-develop.sh | 10 ++++++++-- gitUpdate.sh | 8 +++++++- rebuild-develop.sh | 8 +++++++- start-develop.sh | 8 +++++++- stop-develop.sh | 8 +++++++- 5 files changed, 36 insertions(+), 6 deletions(-) diff --git a/down-develop.sh b/down-develop.sh index f2bfcfe..a1ad1a6 100644 --- a/down-develop.sh +++ b/down-develop.sh @@ -3,7 +3,13 @@ export COMPOSE_PROJECT=codex-develop CODEX_REPOS=${CODEX_REPOS:-"codex-keycloak,codex-feasibility-gui,codex-feasibility-backend,codex-flare"} -baseDir=$(pwd) + +readlink "$0" > /dev/null +if [ $? -ne 0 ]; then + baseDir=$(dirname "$0") +else + baseDir=$(dirname "$(readlink "$0")") +fi for repoName in ${CODEX_REPOS//,/ } @@ -31,4 +37,4 @@ do docker-compose -p $COMPOSE_PROJECT down fi fi -done \ No newline at end of file +done diff --git a/gitUpdate.sh b/gitUpdate.sh index 6e68c4b..e21d7c6 100644 --- a/gitUpdate.sh +++ b/gitUpdate.sh @@ -2,7 +2,13 @@ gitBase="https://github.com/num-codex/" repos=("codex-feasibility-gui" "codex-feasibility-backend" "codex-keycloak" "codex-processes-ap2" "codex-aktin-broker" "codex-sq2cql" "num-knoten" "broker" "codex-flare") -baseDir=$(pwd) + +readlink "$0" > /dev/null +if [ $? -ne 0 ]; then + baseDir=$(dirname "$0") +else + baseDir=$(dirname "$(readlink "$0")") +fi echo "****updating base repo Develop****" git pull diff --git a/rebuild-develop.sh b/rebuild-develop.sh index 1667c0e..f3a4106 100644 --- a/rebuild-develop.sh +++ b/rebuild-develop.sh @@ -3,7 +3,13 @@ export COMPOSE_PROJECT=codex-develop CODEX_REPOS=${CODEX_REPOS:-"codex-keycloak,codex-feasibility-gui,codex-feasibility-backend,codex-flare"} -baseDir=$(pwd) + +readlink "$0" > /dev/null +if [ $? -ne 0 ]; then + baseDir=$(dirname "$0") +else + baseDir=$(dirname "$(readlink "$0")") +fi for repoName in ${CODEX_REPOS//,/ } diff --git a/start-develop.sh b/start-develop.sh index 5337c50..d68b28f 100644 --- a/start-develop.sh +++ b/start-develop.sh @@ -2,9 +2,15 @@ export COMPOSE_PROJECT=codex-develop -baseDir=$(pwd) CODEX_REPOS=${CODEX_REPOS:-"codex-keycloak,codex-feasibility-gui,codex-feasibility-backend,codex-flare"} +readlink "$0" > /dev/null +if [ $? -ne 0 ]; then + baseDir=$(dirname "$0") +else + baseDir=$(dirname "$(readlink "$0")") +fi + export CODEX_CONCEPT_TREE_PATH=${CODEX_CONCEPT_TREE_PATH:-"$baseDir/ontology/codex-code-tree.json"} export CODEX_TERM_CODE_MAPPING_PATH=${CODEX_TERM_CODE_MAPPING_PATH:-"$baseDir/ontology/term-code-mapping.json"} diff --git a/stop-develop.sh b/stop-develop.sh index 60d6497..f99c889 100644 --- a/stop-develop.sh +++ b/stop-develop.sh @@ -3,7 +3,13 @@ export COMPOSE_PROJECT=codex-develop CODEX_REPOS=${CODEX_REPOS:-"codex-keycloak,codex-feasibility-gui,codex-feasibility-backend,codex-flare"} -baseDir=$(pwd) + +readlink "$0" > /dev/null +if [ $? -ne 0 ]; then + baseDir=$(dirname "$0") +else + baseDir=$(dirname "$(readlink "$0")") +fi for repoName in ${CODEX_REPOS//,/ }