run_bepinex.sh 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/bin/sh
  2. # BepInEx running script
  3. #
  4. # This script is used to run a Unity game with BepInEx enabled.
  5. #
  6. # Usage: Configure the script below and simply run this script when you want to run your game modded.
  7. if [ -z "$1" ]; then echo "Please open run.sh in a text editor and configure executable name. Comment or remove this line when you're done." && exit 1; fi
  8. # -------- SETTINGS --------
  9. # ---- EDIT AS NEEDED ------
  10. # EDIT THIS: The name of the executable to run
  11. # LINUX: This is the name of the Unity game executable
  12. # MACOS: This is the name of the game app WITHOUT the .app
  13. executable_name="";
  14. # The rest is automatically handled by BepInEx
  15. # Whether or not to enable Doorstop. Valid values: TRUE or FALSE
  16. export DOORSTOP_ENABLE=TRUE;
  17. # What .NET assembly to execute. Valid value is a path to a .NET DLL that mono can execute.
  18. export DOORSTOP_INVOKE_DLL_PATH=${PWD}/BepInEx/core/BepInEx.Preloader.dll;
  19. # ----- DO NOT EDIT FROM THIS LINE FORWARD ------
  20. # ----- (unless you know what you're doing) ------
  21. # Backup current LD_PRELOAD because it can break `file` when running from Steam
  22. LD_PRELOAD_BAK=$LD_PRELOAD;
  23. export LD_PRELOAD="";
  24. DYLD_INSERT_LIBRARIES_BAK=$DYLD_INSERT_LIBRARIES;
  25. export DYLD_INSERT_LIBRARIES="";
  26. doorstop_libs=${PWD}/doorstop_libs;
  27. arch="";
  28. executable_path="";
  29. lib_postfix="";
  30. os_type=`uname -s`;
  31. case $os_type in
  32. Linux*) executable_path=${PWD}/${executable_name};
  33. lib_postfix="so";;
  34. Darwin*) executable_path=${PWD}/${executable_name}.app/Contents/MacOS/${executable_name};
  35. lib_postfix="dylib";;
  36. *) echo "Cannot identify OS (got $(uname -s))!";
  37. echo "Please create an issue at https://github.com/BepInEx/BepInEx/issues.";
  38. exit 1;;
  39. esac
  40. # Special case: if there is an arg, use that as executable path
  41. # Linux: arg is path to the executable
  42. # MacOS: arg is path to the .app folder which we need to resolve to the exectuable
  43. if [ -n "$1" ]; then
  44. case $os_type in
  45. Linux*) executable_path=$1;;
  46. Darwin*) executable_name=`basename "$1" .app`;
  47. executable_path=$1/Contents/MacOS/$executable_name;;
  48. esac
  49. fi
  50. executable_type=`file -b "${executable_path}"`;
  51. case $executable_type in
  52. *64-bit*) arch="x64";;
  53. *32-bit*|*i386*) arch="x86";;
  54. *) echo "Cannot identify executable type (got ${executable_type})!";
  55. echo "Please create an issue at https://github.com/BepInEx/BepInEx/issues.";
  56. exit 1;;
  57. esac
  58. doorstop_libname=libdoorstop_${arch}.${lib_postfix};
  59. export LD_LIBRARY_PATH=${doorstop_libs}:${LD_LIBRARY_PATH};
  60. export LD_PRELOAD=${doorstop_libs}/$doorstop_libname:$LD_PRELOAD_BAK;
  61. export DYLD_LIBRARY_PATH=${doorstop_libs}:${DYLD_LIBRARY_PATH};
  62. export DYLD_INSERT_LIBRARIES=${doorstop_libs}/$doorstop_libname:$DYLD_INSERT_LIBRARIES_BAK;
  63. "${executable_path}"