diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-08-17 21:41:23 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-11-28 00:01:45 -0500 |
commit | 0f508c755aa679dc63b78507c54b5530d5b972d3 (patch) | |
tree | 4ce48420e2acb622b0c070c5d45828d3cf2a2524 | |
parent | 7c5c63d6846d93f772dfda37f394b5f501f49f25 (diff) | |
download | SMAPI-0f508c755aa679dc63b78507c54b5530d5b972d3.tar.gz SMAPI-0f508c755aa679dc63b78507c54b5530d5b972d3.tar.bz2 SMAPI-0f508c755aa679dc63b78507c54b5530d5b972d3.zip |
reorganize install script
This fixes an issue where Steam messes with the PATH, so dotnet isn't available until the terminal window is opened.
-rw-r--r-- | src/SMAPI.Installer/assets/unix-launcher.sh | 70 |
1 files changed, 44 insertions, 26 deletions
diff --git a/src/SMAPI.Installer/assets/unix-launcher.sh b/src/SMAPI.Installer/assets/unix-launcher.sh index 0e700b61..7e892fca 100644 --- a/src/SMAPI.Installer/assets/unix-launcher.sh +++ b/src/SMAPI.Installer/assets/unix-launcher.sh @@ -1,34 +1,19 @@ #!/usr/bin/env bash -# Move to script's directory +########## +## Initial setup +########## +# move to script's directory cd "$(dirname "$0")" || exit $? -# validate script is being run from the game folder -if [ ! -f "Stardew Valley.dll" ]; then - echo "Oops! SMAPI must be placed in the Stardew Valley game folder.\nSee instructions: https://stardewvalleywiki.com/Modding:Player_Guide"; - read - exit 1 -fi - -# make sure .NET 5 is installed -if ! command -v dotnet >/dev/null 2>&1; then - echo "Oops! You must have .NET 5 installed to use SMAPI: https://dotnet.microsoft.com/download"; - read - exit 1 -fi -# macOS -UNAME=$(uname) -if [ "$UNAME" == "Darwin" ]; then - # fix "DllNotFoundException: libgdiplus.dylib" errors when loading images in SMAPI - if [ -f libgdiplus.dylib ]; then - rm libgdiplus.dylib - fi - if [ -f /Library/Frameworks/Mono.framework/Versions/Current/lib/libgdiplus.dylib ]; then - ln -s /Library/Frameworks/Mono.framework/Versions/Current/lib/libgdiplus.dylib libgdiplus.dylib - fi - - # Make sure we're running in Terminal (so the user can see errors/warnings/update alerts). +########## +## Open terminal if needed +########## +# on macOS, make sure we're running in a Terminal +# Besides letting the player see errors/warnings/alerts in the console, this is also needed because +# Steam messes with the PATH. +if [ "$(uname)" == "Darwin" ]; then if [ ! -t 1 ]; then # https://stackoverflow.com/q/911168/262123 # sanity check to make sure we don't have an infinite loop of opening windows SKIP_TERMINAL=false @@ -51,6 +36,39 @@ if [ "$UNAME" == "Darwin" ]; then exit 0 fi fi +fi + + +########## +## Validate assumptions +########## +# script must be run from the game folder +if [ ! -f "Stardew Valley.dll" ]; then + echo "Oops! SMAPI must be placed in the Stardew Valley game folder.\nSee instructions: https://stardewvalleywiki.com/Modding:Player_Guide"; + read + exit 1 +fi + +# .NET 5 must be installed +if ! command -v dotnet >/dev/null 2>&1; then + echo "Oops! You must have .NET 5 installed to use SMAPI: https://dotnet.microsoft.com/download"; + read + exit 1 +fi + + +########## +## Launch SMAPI +########## +# macOS +if [ "$(uname)" == "Darwin" ]; then + # fix "DllNotFoundException: libgdiplus.dylib" errors when loading images in SMAPI + if [ -f libgdiplus.dylib ]; then + rm libgdiplus.dylib + fi + if [ -f /Library/Frameworks/Mono.framework/Versions/Current/lib/libgdiplus.dylib ]; then + ln -s /Library/Frameworks/Mono.framework/Versions/Current/lib/libgdiplus.dylib libgdiplus.dylib + fi # launch SMAPI dotnet StardewModdingAPI.dll "$@" |