Skip to content

Commit f2347b7

Browse files
authored
Use absolute path when invoking run-helper.sh or Runner.Listener (#1645)
1 parent 8f160bc commit f2347b7

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/Misc/layoutroot/run-helper.sh.template

+9-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,15 @@ safe_sleep() {
2626
fi
2727
}
2828

29-
bin/Runner.Listener run $*
29+
SOURCE="${BASH_SOURCE[0]}"
30+
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
31+
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
32+
SOURCE="$(readlink "$SOURCE")"
33+
[[ $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
34+
done
35+
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
36+
"$DIR"/bin/Runner.Listener run $*
37+
3038
returnCode=$?
3139
if [[ $returnCode == 0 ]]; then
3240
echo "Runner listener exit with 0 return code, stop the service, no retry needed."

src/Misc/layoutroot/run.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
99
[[ $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
1010
done
1111
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
12-
cp -f run-helper.sh.template run-helper.sh
12+
cp -f "$DIR"/run-helper.sh.template "$DIR"/run-helper.sh
1313
# run the helper process which keep the listener alive
1414
while :;
1515
do

0 commit comments

Comments
 (0)