Skip to content

Commit

Permalink
Add absolute path to bash scripts (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsmyth-aquaq authored Sep 28, 2018
1 parent 6c2377a commit c1a6293
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 25 deletions.
9 changes: 7 additions & 2 deletions monit/bin/monit.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#!/bin/bash
#FUNCTION DECLARATION ###############################################################################

cd ../.. && export BASEDIR="${PWD}" && cd - > /dev/null; # set BASEDIR to the root of the torq directory
mkdir -p ../logs
if [ "-bash" = $0 ]; then
BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
else
BASEDIR="$(cd "$(dirname "$0")" && pwd)"
fi
BASEDIR=$(dirname $(dirname $BASEDIR)) # set BASEDIR to root of TorQ directory
mkdir -p ${BASEDIR}/monit/logs # create directory for monit logs

checkst(){
#function to check if file exists
Expand Down
14 changes: 8 additions & 6 deletions setenv.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#!/bin/bash

if [ "-bash" = $0 ]; then
dirpath="${BASH_SOURCE[0]}"
dirpath="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
else
dirpath="$0"
dirpath="$(cd "$(dirname "$0")" && pwd)"
fi

export TORQHOME=$(dirname $dirpath) # if running the kdb+tick example, change these to full paths
export TORQDATA=$(dirname $dirpath) # some of the kdb+tick processes will change directory, and these will no longer be valid
export TORQAPPHOME=$(dirname $dirpath)
export TORQHOME=$dirpath # if running the kdb+tick example, change these to full paths
export TORQDATA=$dirpath # some of the kdb+tick processes will change directory, and these will no longer be valid
export TORQAPPHOME=$dirpath

export KDBLOG=${TORQDATA}/logs
export KDBHTML=${TORQHOME}/html
Expand All @@ -24,4 +26,4 @@ export TORQPROCESSES=${KDBAPPCONFIG}/process.csv

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$KDBLIB/l32

export TORQMONIT=${TORQHOME}/logs/monit # set the folder for monit outputs
export TORQMONIT=${TORQHOME}/logs/monit # set the folder for monit outputs
36 changes: 19 additions & 17 deletions torq.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
#!/bin/bash
#!/bin/bash

if [ "-bash" = $0 ]; then
dirpath="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
else
dirpath="$(cd "$(dirname "$0")" && pwd)"
fi

if [ -z $SETENV ]; then
SETENV=${dirpath}/setenv.sh # set the environment if not predefined
fi

if [ -f $SETENV ]; then # check script exists
. $SETENV # load the environment
else
echo "ERROR: Failed to load environment - $SETENV: No such file or directory" # show input file error
exit 1
fi


getfield() {
fieldno=$(awk -F, '{if(NR==1) for(i=1;i<=NF;i++){if($i=="'$2'") print i}}' "$CSVPATH") # get number for field based on headers
Expand Down Expand Up @@ -214,22 +232,6 @@ usage() {
exit 1
}

if [ "-bash" = $0 ]; then
dirpath="${BASH_SOURCE[0]}"
else
dirpath="$0"
fi

if [[ -z $SETENV ]]; then
SETENV=$(dirname $dirpath)/setenv.sh; # set the environment if not predefined
fi

if [ -f $SETENV ]; then # check script exists
. $SETENV # load the environment
else
echo "ERROR: Failed to load environment - $SETENV: No such file or directory" # show input file error
exit 1
fi

case $1 in
start)
Expand Down

0 comments on commit c1a6293

Please sign in to comment.