From 31bd32e7efadcb88cf24367c304ac57dbecb2014 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 13 Nov 2021 13:38:49 +0000 Subject: [PATCH] Allow launcher scripts to run from other working directories. --- launch-dedicated.sh | 5 +++-- launch-game.sh | 5 +++-- utility.sh | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/launch-dedicated.sh b/launch-dedicated.sh index f594852ebf..8e69f6c068 100755 --- a/launch-dedicated.sh +++ b/launch-dedicated.sh @@ -6,7 +6,8 @@ # $ Mod="d2k" ./launch-dedicated.sh # Launch a dedicated server with default settings but override the Mod # Read the file to see which settings you can override -if command -v mono >/dev/null 2>&1 && [ "$(grep -c .NETCoreApp,Version= bin/OpenRA.Server.dll)" = "0" ]; then +ENGINEDIR=$(dirname "$0") +if command -v mono >/dev/null 2>&1 && [ "$(grep -c .NETCoreApp,Version= ${ENGINEDIR}/bin/OpenRA.Server.dll)" = "0" ]; then RUNTIME_LAUNCHER="mono --debug" else RUNTIME_LAUNCHER="dotnet" @@ -34,7 +35,7 @@ JoinChatDelay="${JoinChatDelay:-"5000"}" SupportDir="${SupportDir:-""}" while true; do - ${RUNTIME_LAUNCHER} bin/OpenRA.Server.dll Engine.EngineDir=".." Game.Mod="$Mod" \ + ${RUNTIME_LAUNCHER} ${ENGINEDIR}/bin/OpenRA.Server.dll Engine.EngineDir=".." Game.Mod="$Mod" \ Server.Name="$Name" \ Server.ListenPort="$ListenPort" \ Server.AdvertiseOnline="$AdvertiseOnline" \ diff --git a/launch-game.sh b/launch-game.sh index 9a0072aad5..01adb1bb1d 100755 --- a/launch-game.sh +++ b/launch-game.sh @@ -1,5 +1,6 @@ #!/bin/sh -if command -v mono >/dev/null 2>&1 && [ "$(grep -c .NETCoreApp,Version= bin/OpenRA.dll)" = "0" ]; then +ENGINEDIR=$(dirname "$0") +if command -v mono >/dev/null 2>&1 && [ "$(grep -c .NETCoreApp,Version= ${ENGINEDIR}/bin/OpenRA.dll)" = "0" ]; then RUNTIME_LAUNCHER="mono --debug" else RUNTIME_LAUNCHER="dotnet" @@ -31,7 +32,7 @@ then fi # Launch the engine with the appropriate arguments -${RUNTIME_LAUNCHER} bin/OpenRA.dll Engine.EngineDir=".." Engine.LaunchPath="${LAUNCHPATH}" ${MODARG} "$@" +${RUNTIME_LAUNCHER} ${ENGINEDIR}/bin/OpenRA.dll Engine.EngineDir=".." Engine.LaunchPath="${LAUNCHPATH}" ${MODARG} "$@" # Show a crash dialog if something went wrong if [ $? != 0 ] && [ $? != 1 ]; then diff --git a/utility.sh b/utility.sh index dc002d25ce..22c94a029d 100755 --- a/utility.sh +++ b/utility.sh @@ -1,8 +1,9 @@ #!/bin/sh -if command -v mono >/dev/null 2>&1 && [ "$(grep -c .NETCoreApp,Version= bin/OpenRA.Utility.dll)" = "0" ]; then +ENGINEDIR=$(dirname "$0") +if command -v mono >/dev/null 2>&1 && [ "$(grep -c .NETCoreApp,Version= ${ENGINEDIR}/bin/OpenRA.Utility.dll)" = "0" ]; then RUNTIME_LAUNCHER="mono --debug" else RUNTIME_LAUNCHER="dotnet" fi -ENGINE_DIR=.. ${RUNTIME_LAUNCHER} bin/OpenRA.Utility.dll "$@" +ENGINE_DIR=.. ${RUNTIME_LAUNCHER} ${ENGINEDIR}/bin/OpenRA.Utility.dll "$@"