run_bepinex.sh 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 WITHOUT the .app
  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_path="${PWD}/${executable_name}.app/Contents/MacOS/${executable_name}"
  36. lib_postfix="dylib"
  37. ;;
  38. *)
  39. echo "Cannot identify OS (got $(uname -s))!"
  40. echo "Please create an issue at https://github.com/BepInEx/BepInEx/issues."
  41. exit 1
  42. ;;
  43. esac
  44. # Special case: if there is an arg, use that as executable path
  45. # Linux: arg is path to the executable
  46. # MacOS: arg is path to the .app folder which we need to resolve to the exectuable
  47. if [ -n "$1" ]; then
  48. case $os_type in
  49. Linux*)
  50. executable_path="$1"
  51. ;;
  52. Darwin*)
  53. executable_name=`basename "$1" .app`
  54. executable_path="$1/Contents/MacOS/$executable_name"
  55. ;;
  56. esac
  57. fi
  58. executable_type=`LD_PRELOAD="" file -b "${executable_path}"`;
  59. case $executable_type in
  60. *64-bit*)
  61. arch="x64"
  62. ;;
  63. *32-bit*|*i386*)
  64. arch="x86"
  65. ;;
  66. *)
  67. echo "Cannot identify executable type (got ${executable_type})!"
  68. echo "Please create an issue at https://github.com/BepInEx/BepInEx/issues."
  69. exit 1
  70. ;;
  71. esac
  72. doorstop_libname=libdoorstop_${arch}.${lib_postfix}
  73. export LD_LIBRARY_PATH="${doorstop_libs}":${LD_LIBRARY_PATH}
  74. export LD_PRELOAD=$doorstop_libname:$LD_PRELOAD
  75. export DYLD_LIBRARY_PATH="${doorstop_libs}"
  76. export DYLD_INSERT_LIBRARIES=$doorstop_libname
  77. "${executable_path}"