install.sh 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #!/usr/bin/env bash
  2. # HI3 patch by mkrsym1
  3. # https://notabug.org/mkrsym1/dusk
  4. script_dir=`dirname $0`
  5. source "${script_dir}"/common
  6. if [ "$(realpath "${script_dir}")" == "$(realpath .)" ]; then
  7. error "Do not put the patch installer into the game directory!"
  8. fi
  9. root_cmd="pkexec"
  10. yes_to_all=""
  11. # Parse commandline arguments
  12. while [ "x$1" != "x" ];
  13. do
  14. case $1 in
  15. --root-cmd)
  16. shift
  17. root_cmd="$1"
  18. ;;
  19. --yes-to-all)
  20. yes_to_all="1"
  21. ;;
  22. *)
  23. error "Invalid commandline argmument: $1"
  24. ;;
  25. esac
  26. shift
  27. done
  28. # File checksums
  29. bh3base_checksum=($(md5sum BH3Base.dll))
  30. if [ "${bh3base_checksum}" != "a8a9faa460be9c6fd1d0a0f7fe62a678" ]; then
  31. error "BH3Base.dll: wrong file version or file is already patched. Run uninstall.sh to remove the patch."
  32. fi
  33. unityplayer_checksum=($(md5sum UnityPlayer.dll))
  34. if [ "${unityplayer_checksum}" != "27fbee826303858eb28ccd5dc4a67b43" ]; then
  35. error "UnityPlayer.dll: wrong file version or file is already patched. Run uninstall.sh to remove the patch."
  36. fi
  37. if [ "${yes_to_all}" != "1" ]; then
  38. echo
  39. 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!"
  40. read -p "Do you wish to proceed? [y/N] " response
  41. if [[ ! "$response" == [Yy]* ]]; then
  42. exit 1
  43. fi
  44. fi
  45. # Remove after testing
  46. if [ "${yes_to_all}" != "1" ]; then
  47. echo
  48. echo "This patch is very new. There is a serious risk of your account getting banned!"
  49. read -p "Do you still wish to proceed? [y/N] " response
  50. if [[ ! "$response" == [Yy]* ]]; then
  51. exit 1
  52. fi
  53. fi
  54. echo
  55. info "Installing the patch"
  56. logging_servers=$(cat <<EOF
  57. # Honkai Impact 3rd logging servers
  58. 0.0.0.0 log-upload-os.hoyoverse.com
  59. 0.0.0.0 sg-public-data-api.hoyoverse.com
  60. 0.0.0.0 dump.gamesafe.qq.com
  61. EOF
  62. )
  63. echo
  64. if [[ ! `cat /etc/hosts` == *"$logging_servers"* ]]; then
  65. info "Blocking logging servers. This will require superuser privileges (canceling will skip this step)"
  66. echo "$logging_servers" | $root_cmd tee -a /etc/hosts 2>&1 >> /dev/null
  67. if test $? -ne 0; then
  68. warn "Could not block logging servers. Please add the following lines to your /etc/hosts manually:"
  69. echo "$logging_servers"
  70. fi
  71. else
  72. info "Logging servers are already blocked"
  73. fi
  74. echo
  75. info "Copying additional files"
  76. for additional_file in ${additional_files[@]}
  77. do
  78. info "Copying ${additional_file}"
  79. cp -r "${script_dir}/files/${additional_file}" .
  80. done
  81. echo
  82. info "Pathing game files"
  83. for game_file in ${game_files[@]}
  84. do
  85. if test -f "${game_file}"; then
  86. info "Patching ${game_file}"
  87. xdelta3 -d -s "${game_file}" "${script_dir}/diffs/${game_file}.vcdiff" "${game_file}.p"
  88. mv "${game_file}" "${game_file}.bak"
  89. mv "${game_file}.p" "${game_file}"
  90. else
  91. error "${game_file} not found!"
  92. fi
  93. done
  94. echo
  95. info "Done"
  96. echo
  97. echo "!!! PLEASE DON'T SHARE THIS PROJECT IN PUBLIC !!!"
  98. echo