diff --git a/src/Misc/layoutroot/run-helper.sh.template b/src/Misc/layoutroot/run-helper.sh.template index ef54bd516..7334ec981 100755 --- a/src/Misc/layoutroot/run-helper.sh.template +++ b/src/Misc/layoutroot/run-helper.sh.template @@ -26,7 +26,15 @@ safe_sleep() { fi } -bin/Runner.Listener run $* +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 )" +"$DIR"/bin/Runner.Listener run $* + returnCode=$? if [[ $returnCode == 0 ]]; then echo "Runner listener exit with 0 return code, stop the service, no retry needed." diff --git a/src/Misc/layoutroot/run.sh b/src/Misc/layoutroot/run.sh index 580ab934f..f53bae5f0 100755 --- a/src/Misc/layoutroot/run.sh +++ b/src/Misc/layoutroot/run.sh @@ -9,7 +9,7 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli [[ $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 )" -cp -f run-helper.sh.template run-helper.sh +cp -f "$DIR"/run-helper.sh.template "$DIR"/run-helper.sh # run the helper process which keep the listener alive while :; do