Mercurial > public > ssdt-docker
changeset 143:c029be781d13
DEP-12: handle symlinks in home discovery
author | smith@nwoca.org |
---|---|
date | Wed, 05 Jul 2017 22:12:06 +0100 |
parents | 923c2b21fac7 |
children | 249ec634da33 |
files | init.sh scripts/.functions.sh |
diffstat | 2 files changed, 24 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/init.sh Fri Jun 16 17:14:16 2017 +0100 +++ b/init.sh Wed Jul 05 22:12:06 2017 +0100 @@ -1,6 +1,14 @@ #!/bin/bash -source "$( dirname "${BASH_SOURCE[0]}")/scripts/.functions.sh" +getSsdtHomeDir() { + SOURCE="${BASH_SOURCE[0]}" + while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done + echo $( cd $( dirname $SOURCE) && pwd ) +} + +echo ${BASH_SOURCE[*]} +export SSDT_HOME=$(getSsdtHomeDir) +export SSDT_SCRIPTS=${SSDT_HOME}/scripts +echo "ssdt_home $SSDT_HOME ($SSDT_SCRIPTS)" +source "${SSDT_SCRIPTS}/.functions.sh" alias utils='docker run -it -v ${PWD}:/tmp -v $SSDT_HOME:/ssdt --rm docker.ssdt.io/ssdt-utils' -alias send2ssdt='/ssdt/scripts/send.sh' - -export PATH=$PATH:$SSDT_HOME/scripts +alias send2ssdt='${SSDT_SCRIPTS}/send.sh'
--- 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() {