From 3507083bea654955185334fdb7cb4d3073738c35 Mon Sep 17 00:00:00 2001 From: Joseph Edmonds Date: Thu, 8 Mar 2018 17:29:19 +0000 Subject: [PATCH] brought back the old symlink resolving logic, works better --- .gitignore | 2 +- bin/download-binaries.bash | 12 +++++++++--- bin/selenium-background-run.bash | 12 +++++++++--- bin/selenium-run.bash | 12 +++++++++--- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 2f7fcdf..8d7b1c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ /vendor/ .idea/ -nohup.out \ No newline at end of file +*nohup.out diff --git a/bin/download-binaries.bash b/bin/download-binaries.bash index f3c99da..07991af 100644 --- a/bin/download-binaries.bash +++ b/bin/download-binaries.bash @@ -1,6 +1,12 @@ #!/usr/bin/env bash -DIR=$(dirname $(readlink -f "$0")) -cd $DIR; +source="${BASH_SOURCE[0]}" +while [ -h "$source" ]; do # resolve $SOURCE until the file is no longer a symlink + dir="$( cd -P "$( dirname "$source" )" && pwd )" + source="$(readlink "$source")" + [[ $source != /* ]] && source="$dir/$source" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +dir="$( cd -P "$( dirname "$source" )" && pwd )" +cd $dir; set -e set -u set -o pipefail @@ -22,7 +28,7 @@ currentChromedriverVersionFile=current_chromedriver_version.txt firefoxdriverVersion=0.15.0 firefoxdriverFile=geckodriver -cd $DIR/../binaries/ +cd $dir/../binaries/ if [[ $? != 0 ]] then echo "Failed cd-ing into the the binaries folder, aborting" diff --git a/bin/selenium-background-run.bash b/bin/selenium-background-run.bash index 3d4cf4e..b0dedef 100755 --- a/bin/selenium-background-run.bash +++ b/bin/selenium-background-run.bash @@ -1,6 +1,12 @@ #!/usr/bin/env bash -DIR=$(dirname $(readlink -f "$0")) -cd $DIR +source="${BASH_SOURCE[0]}" +while [ -h "$source" ]; do # resolve $SOURCE until the file is no longer a symlink + dir="$( cd -P "$( dirname "$source" )" && pwd )" + source="$(readlink "$source")" + [[ $source != /* ]] && source="$dir/$source" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +dir="$( cd -P "$( dirname "$source" )" && pwd )" +cd $dir; source ./download-binaries.bash @@ -8,7 +14,7 @@ echo '' > nohup.out echo " Starting Selenium in the Background " -nohup $DIR/selenium-run.bash "$@" & +nohup $dir/selenium-run.bash "$@" & sleep 2 diff --git a/bin/selenium-run.bash b/bin/selenium-run.bash index 2dce9cb..3305592 100755 --- a/bin/selenium-run.bash +++ b/bin/selenium-run.bash @@ -1,6 +1,12 @@ #!/usr/bin/env bash -DIR=$(dirname $(readlink -f "$0")) -cd $DIR; +source="${BASH_SOURCE[0]}" +while [ -h "$source" ]; do # resolve $SOURCE until the file is no longer a symlink + dir="$( cd -P "$( dirname "$source" )" && pwd )" + source="$(readlink "$source")" + [[ $source != /* ]] && source="$dir/$source" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +dir="$( cd -P "$( dirname "$source" )" && pwd )" +cd $dir; set -e set -u set -o pipefail @@ -57,7 +63,7 @@ fi echo "Now Starting Selenium" echo "Killing if already running:" -bash $DIR/selenium-stop.bash +bash $dir/selenium-stop.bash if [[ "$@" =~ .*firefox.* ]]