diff scripts/.functions.sh @ 143:c029be781d13

DEP-12: handle symlinks in home discovery
author smith@nwoca.org
date Wed, 05 Jul 2017 22:12:06 +0100
parents 8f45c43ea7a4
children 249ec634da33
line wrap: on
line diff
--- a/scripts/.functions.sh	Fri Jun 16 17:14:16 2017 +0100
+++ b/scripts/.functions.sh	Wed Jul 05 22:12:06 2017 +0100
@@ -1,6 +1,16 @@
 #!/bin/bash
-export SSDT_SCRIPTS=$(dirname "${BASH_SOURCE[0]}")
-export SSDT_HOME=$(dirname $SSDT_SCRIPTS)
+
+getScriptDir() {
+     SOURCE="${BASH_SOURCE[0]}"
+     while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
+     echo $( cd $( dirname $SOURCE) && pwd )
+}
+
+if [ "$SSDT_HOME" == "" ]
+then
+   export SSDT_SCRIPTS=$(getScriptDir)
+   export SSDT_HOME=$(dirname $SSDT_SCRIPTS)
+fi
 
 # deletes psql data from specified service
 resetDbVolume() {