install.sh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #!/usr/bin/env bash
  2. # HI3 patch by mkrsym1
  3. # https://notabug.org/mkrsym1/dusk
  4. # mirror: https://codeberg.org/an-anime-team/dusk
  5. script_dir=`dirname "$0"`
  6. source "${script_dir}"/common
  7. if [ "$(realpath "${script_dir}")" == "$(realpath .)" ]; then
  8. error "Do not put the patch installer into the game directory!"
  9. fi
  10. if ! command -v xdelta3 2>&1 >> /dev/null; then
  11. error "xdelta3 is required for patching the game files, but was not found!"
  12. fi
  13. root_cmd="pkexec"
  14. yes_to_all=""
  15. no_root=""
  16. # Parse commandline arguments
  17. while [ "x$1" != "x" ];
  18. do
  19. case $1 in
  20. --root-cmd)
  21. shift
  22. root_cmd="$1"
  23. ;;
  24. --yes-to-all)
  25. yes_to_all="1"
  26. ;;
  27. --no-root)
  28. no_root="1"
  29. ;;
  30. *)
  31. error "Invalid commandline argmument: $1"
  32. ;;
  33. esac
  34. shift
  35. done
  36. # Logging servers
  37. logging_servers_glb=$(cat <<EOF
  38. # Honkai Impact 3rd logging servers
  39. 0.0.0.0 log-upload-os.hoyoverse.com
  40. 0.0.0.0 sg-public-data-api.hoyoverse.com
  41. 0.0.0.0 dump.gamesafe.qq.com
  42. EOF
  43. )
  44. # Region detection
  45. game_region=""
  46. logging_servers=""
  47. bh3base_checksum=($(md5sum BH3Base.dll))
  48. unityplayer_checksum=($(md5sum UnityPlayer.dll))
  49. case "${bh3base_checksum}-${unityplayer_checksum}" in
  50. "8cf160412eac779064456bcf5a408005-94ca69db1084ad419e124093cdfbc1eb")
  51. game_region="glb"
  52. logging_servers="${logging_servers_glb}"
  53. ;;
  54. *)
  55. error "Wrong game version or game is already patched. Run uninstall.sh to remove the patch."
  56. ;;
  57. esac
  58. info "Detected region: ${game_region}"
  59. if ! [ "${yes_to_all}" ]; then
  60. echo
  61. echo "Modifying the game is a violation of it's Terms of Service! Make sure that you understand all of the risks and possible consequences before proceeding!"
  62. read -p "Do you wish to proceed? [y/N] " response
  63. if [[ ! "$response" == [Yy]* ]]; then
  64. exit 1
  65. fi
  66. fi
  67. echo
  68. info "Installing the patch"
  69. echo
  70. if ! [ "${no_root}" ]; then
  71. if [[ ! `cat /etc/hosts` == *"$logging_servers"* ]]; then
  72. info "Blocking logging servers. This will require superuser privileges (canceling will skip this step)"
  73. echo "$logging_servers" | $root_cmd tee -a /etc/hosts 2>&1 >> /dev/null
  74. if test $? -ne 0; then
  75. warn "Could not block logging servers. Please add the following lines to your /etc/hosts manually:"
  76. echo "$logging_servers"
  77. fi
  78. else
  79. info "Logging servers are already blocked"
  80. fi
  81. else
  82. info "Skipped blocking logging servers because of --no-root"
  83. fi
  84. echo
  85. info "Copying additional files"
  86. for additional_file in ${additional_files[@]}
  87. do
  88. info "Copying ${additional_file}"
  89. cp -r "${script_dir}/${game_region}/files/${additional_file}" .
  90. if test $? -ne 0; then
  91. error "Failed to copy ${additional_file}!"
  92. fi
  93. done
  94. echo
  95. info "Patching game files"
  96. for game_file in ${game_files[@]}
  97. do
  98. if test -f "${game_file}"; then
  99. info "Patching ${game_file}"
  100. mv "${game_file}" "${game_file}.bak"
  101. xdelta3 -d -s "${game_file}.bak" "${script_dir}/${game_region}/diffs/${game_file}.vcdiff" "${game_file}"
  102. if test $? -ne 0; then
  103. error "Failed to patch ${game_file}!"
  104. fi
  105. else
  106. error "${game_file} not found!"
  107. fi
  108. done
  109. echo
  110. info "Done"
  111. echo
  112. echo "!!! PLEASE DON'T SHARE THIS PROJECT IN PUBLIC !!!"
  113. echo