66# Source this file from the .source script. You can also include additional environment
77# variables such as DBSYNC_SCHEMA_DIR and GITHUB_TOKEN in that file, or change INSTANCE_NUM.
88#
9+
10+ [ -n " ${BASH_VERSION:- } " ] || {
11+ echo " This script must be sourced from bash." >&2
12+ return 1
13+ }
14+
915# export DBSYNC_SCHEMA_DIR="$HOME/Source/repos/cardano-db-sync/schema"
1016# export GITHUB_TOKEN=ghp_....
1117INSTANCE_NUM=" ${INSTANCE_NUM:- 0} "
1218
13- # Ensure we are in the correct directory
14- if [[ " ${PWD##*/ } " != " cardano-node-tests" * ]]; then
15- echo " Must be in cardano-node-tests* directory" >&2
16- return 1
17- fi
19+ _ROOT_DIR_CNT=" $( readlink -m " ${BASH_SOURCE[0]} /.." ) "
1820
1921# Activate poetry virtual environment
2022if [ -z " ${VIRTUAL_ENV:- } " ]; then
@@ -39,9 +41,9 @@ unset BOOTSTRAP_DIR
3941mkdir -p " ${CARDANO_NODE_SOCKET_PATH%/* } "
4042
4143# Set temporary directory for this instance
42- TMPDIR=" $PWD /tmp"
44+ TMPDIR=" $_ROOT_DIR_CNT /tmp"
4345if [ " $INSTANCE_NUM " != 0 ]; then
44- TMPDIR=" $PWD /tmp${INSTANCE_NUM} "
46+ TMPDIR=" $_ROOT_DIR_CNT /tmp${INSTANCE_NUM} "
4547fi
4648mkdir -p " $TMPDIR "
4749export TMPDIR
@@ -51,13 +53,16 @@ PATH="$(echo "$PATH" | tr ":" "\n" | grep -v "ghcup" | tr "\n" ":" | sed 's/:*$/
5153export PATH
5254
5355# Prepend instance-specific .bin directory to PATH if it exists and if not already present
54- if [ -e " $PWD /.bin${INSTANCE_NUM} " ] && [[ " :$PATH :" != * " :$PWD /.bin${INSTANCE_NUM} :" * ]]; then
55- export PATH=" $PWD /.bin${INSTANCE_NUM} :$PATH "
56+ if [ -e " $_ROOT_DIR_CNT /.bin${INSTANCE_NUM} " ] \
57+ && [[ " :$PATH :" != * " :$_ROOT_DIR_CNT /.bin${INSTANCE_NUM} :" * ]]; then
58+ export PATH=" $_ROOT_DIR_CNT /.bin${INSTANCE_NUM} :$PATH "
5659fi
5760
5861# Prepend default .bin directory to PATH for instance 0 if it exists and if not already present
59- if [ " $INSTANCE_NUM " = 0 ] && [ -e " $PWD /.bin" ] && [[ " :$PATH :" != * " :$PWD /.bin:" * ]]; then
60- export PATH=" $PWD /.bin:$PATH "
62+ if [ " $INSTANCE_NUM " = 0 ] \
63+ && [ -e " $_ROOT_DIR_CNT /.bin" ] \
64+ && [[ " :$PATH :" != * " :$_ROOT_DIR_CNT /.bin:" * ]]; then
65+ export PATH=" $_ROOT_DIR_CNT /.bin:$PATH "
6166fi
6267
6368# Set database connection environment variables for db-sync
@@ -68,10 +73,10 @@ if [ -n "${DBSYNC_SCHEMA_DIR:-}" ] && command -v cardano-smash-server >/dev/null
6873 export SMASH=true
6974fi
7075
76+ unset INSTANCE_NUM _ROOT_DIR_CNT
77+
7178# Enable cardano-cli bash completion
7279if ! command -v _cardano-cli > /dev/null 2>&1 && command -v cardano-cli > /dev/null 2>&1 ; then
7380 # shellcheck disable=SC1090
7481 . <( cardano-cli --bash-completion-script cardano-cli)
7582fi
76-
77- unset INSTANCE_NUM
0 commit comments