at 24.05-pre 76 lines 2.5 kB view raw
1From 84b2fcdf042771ae8adc0f59f1a3ecd9788a808d Mon Sep 17 00:00:00 2001 2From: Vincent Haupert <mail@vincent-haupert.de> 3Date: Sun, 26 Feb 2023 11:37:01 +0100 4Subject: [PATCH] Access `.env` and `.path` relative to `$RUNNER_ROOT`, if set 5 6--- 7 src/Misc/layoutbin/runsvc.sh | 4 ++-- 8 src/Misc/layoutroot/env.sh | 10 +++++----- 9 src/Runner.Listener/Program.cs | 2 +- 10 3 files changed, 8 insertions(+), 8 deletions(-) 11 12diff --git a/src/Misc/layoutbin/runsvc.sh b/src/Misc/layoutbin/runsvc.sh 13index c135645..bb0fbf6 100755 14--- a/src/Misc/layoutbin/runsvc.sh 15+++ b/src/Misc/layoutbin/runsvc.sh 16@@ -4,9 +4,9 @@ 17 # for more info on how to propagate SIGTERM to a child process see: http://veithen.github.io/2014/11/16/sigterm-propagation.html 18 trap 'kill -INT $PID' TERM INT 19 20-if [ -f ".path" ]; then 21+if [ -f "${RUNNER_ROOT:-"."}/.path" ]; then 22 # configure 23- export PATH=`cat .path` 24+ export PATH=`cat "${RUNNER_ROOT:-"."}/.path"` 25 echo ".path=${PATH}" 26 fi 27 28diff --git a/src/Misc/layoutroot/env.sh b/src/Misc/layoutroot/env.sh 29index 641d244..85379bf 100755 30--- a/src/Misc/layoutroot/env.sh 31+++ b/src/Misc/layoutroot/env.sh 32@@ -16,10 +16,10 @@ varCheckList=( 33 34 envContents="" 35 36-if [ -f ".env" ]; then 37- envContents=`cat .env` 38+if [ -f "${RUNNER_ROOT:-"."}/.env" ]; then 39+ envContents=`cat "${RUNNER_ROOT:-"."}/.env"` 40 else 41- touch .env 42+ touch "${RUNNER_ROOT:-"."}/.env" 43 fi 44 45 function writeVar() 46@@ -29,12 +29,12 @@ function writeVar() 47 if test "${envContents#*$checkDelim}" = "$envContents" 48 then 49 if [ ! -z "${!checkVar}" ]; then 50- echo "${checkVar}=${!checkVar}">>.env 51+ echo "${checkVar}=${!checkVar}">>"${RUNNER_ROOT:-"."}/.env" 52 fi 53 fi 54 } 55 56-echo $PATH>.path 57+echo $PATH>"${RUNNER_ROOT:-"."}/.path" 58 59 for var_name in ${varCheckList[@]} 60 do 61diff --git a/src/Runner.Listener/Program.cs b/src/Runner.Listener/Program.cs 62index d4d5e43..beacc9d 100644 63--- a/src/Runner.Listener/Program.cs 64+++ b/src/Runner.Listener/Program.cs 65@@ -148,7 +148,7 @@ namespace GitHub.Runner.Listener 66 private static void LoadAndSetEnv() 67 { 68 var binDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); 69- var rootDir = new DirectoryInfo(binDir).Parent.FullName; 70+ var rootDir = Environment.GetEnvironmentVariable("RUNNER_ROOT") ?? new DirectoryInfo(binDir).Parent.FullName; 71 string envFile = Path.Combine(rootDir, ".env"); 72 if (File.Exists(envFile)) 73 { 74-- 752.38.1 76