run_bepinex.sh 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. # -------- SETTINGS --------
  8. # ---- EDIT AS NEEDED ------
  9. # EDIT THIS: The name of the executable to run
  10. # LINUX: This is the name of the Unity game executable
  11. # MACOS: This is the name of the game app folder, include the .app suffix
  12. executable_name=""
  13. # The rest is automatically handled by BepInEx
  14. # Whether or not to enable Doorstop. Valid values: TRUE or FALSE
  15. export DOORSTOP_ENABLE=TRUE
  16. # What .NET assembly to execute. Valid value is a path to a .NET DLL that mono can execute.
  17. export DOORSTOP_INVOKE_DLL_PATH="${PWD}/BepInEx/core/BepInEx.Preloader.dll"
  18. # ----- DO NOT EDIT FROM THIS LINE FORWARD ------
  19. # ----- (unless you know what you're doing) ------
  20. if [ ! -x "$1" -a ! -x "$executable_name" ]; then
  21. echo "Please open run.sh in a text editor and configure executable name."
  22. exit 1
  23. fi
  24. doorstop_libs="${PWD}/doorstop_libs"
  25. arch=""
  26. executable_path=""
  27. lib_postfix=""
  28. os_type=`uname -s`
  29. case $os_type in
  30. Linux*)
  31. executable_path="${PWD}/${executable_name}"
  32. lib_postfix="so"
  33. ;;
  34. Darwin*)
  35. executable_name=`basename "${executable_name}" .app`
  36. executable_path="${PWD}/${executable_name}.app/Contents/MacOS/${executable_name}"
  37. lib_postfix="dylib"
  38. ;;
  39. *)
  40. echo "Cannot identify OS (got $(uname -s))!"
  41. echo "Please create an issue at https://github.com/BepInEx/BepInEx/issues."
  42. exit 1
  43. ;;
  44. esac
  45. # Special case: if there is an arg, use that as executable path
  46. # Linux: arg is path to the executable
  47. # MacOS: arg is path to the .app folder which we need to resolve to the exectuable
  48. if [ -n "$1" ]; then
  49. case $os_type in
  50. Linux*)
  51. executable_path="$1"
  52. ;;
  53. Darwin*)
  54. executable_name=`basename "$1" .app`
  55. executable_path="$1/Contents/MacOS/$executable_name"
  56. ;;
  57. esac
  58. fi
  59. executable_type=`LD_PRELOAD="" file -b "${executable_path}"`;
  60. case $executable_type in
  61. *64-bit*)
  62. arch="x64"
  63. ;;
  64. *32-bit*|*i386*)
  65. arch="x86"
  66. ;;
  67. *)
  68. echo "Cannot identify executable type (got ${executable_type})!"
  69. echo "Please create an issue at https://github.com/BepInEx/BepInEx/issues."
  70. exit 1
  71. ;;
  72. esac
  73. doorstop_libname=libdoorstop_${arch}.${lib_postfix}
  74. export LD_LIBRARY_PATH="${doorstop_libs}":${LD_LIBRARY_PATH}
  75. export LD_PRELOAD=$doorstop_libname:$LD_PRELOAD
  76. export DYLD_LIBRARY_PATH="${doorstop_libs}"
  77. export DYLD_INSERT_LIBRARIES="${doorstop_libs}/$doorstop_libname"
  78. "${executable_path}"