fix_csgo.sh 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. # LinuxGSM fix_csgo.sh module
  3. # Author: Daniel Gibbs
  4. # Contributors: https://linuxgsm.com/contrib
  5. # Website: https://linuxgsm.com
  6. # Description: Resolves issues with Counter-Strike: Global Offensive.
  7. moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  8. # Server files are downloaded using App ID 740 (appid), but the App ID written to steam_appid.txt and steam.inf
  9. # (clientappid) decides which client can connect: 4465480 for standalone CS:GO, 730 for the CS2 csgo_legacy branch.
  10. # SteamCMD update/validate can revert these files, so this runs before every start.
  11. # Fixes: server not always creating steam_appid.txt file.
  12. # The server writes steam_appid.txt with a trailing null byte, which is removed before comparing.
  13. if [ -n "${clientappid}" ] && { [ ! -f "${serverfiles}/steam_appid.txt" ] || [ "$(tr -d '\0' < "${serverfiles}/steam_appid.txt")" != "${clientappid}" ]; }; then
  14. fixname="${clientappid} steam_appid.txt"
  15. fn_fix_msg_start
  16. if echo -n "${clientappid}" > "${serverfiles}/steam_appid.txt"; then
  17. exitcode=0
  18. else
  19. exitcode=1
  20. fi
  21. fn_fix_msg_end
  22. fi
  23. # Fixes: steam.inf not using the client App ID.
  24. # steam.inf uses CRLF line endings, the whole value is replaced while keeping the line ending.
  25. if [ -n "${clientappid}" ] && [ -f "${systemdir}/steam.inf" ] && grep -q "^appID=" "${systemdir}/steam.inf" && ! grep -qE "^appID=${clientappid}[[:cntrl:]]?$" "${systemdir}/steam.inf"; then
  26. fixname="${clientappid} steam.inf"
  27. fn_fix_msg_start
  28. sed -i "s/^appID=[^[:cntrl:]]*/appID=${clientappid}/" "${systemdir}/steam.inf"
  29. exitcode=$?
  30. fn_fix_msg_end
  31. fi
  32. # Fixes: Error parsing BotProfile.db - unknown attribute 'Rank'".
  33. if [ -f "${systemdir}/botprofile.db" ] && grep "^\s*Rank" "${systemdir}/botprofile.db" > /dev/null 2>&1; then
  34. fixname="botprofile.db"
  35. fn_fix_msg_start
  36. sed -i 's/^\s*Rank/\t\/\/Rank/g' "${systemdir}/botprofile.db" > /dev/null 2>&1
  37. fn_fix_msg_end
  38. fi
  39. # Fixes: Unknown command "cl_bobamt_vert" and exec: couldn't exec joystick.cfg.
  40. if [ -f "${servercfgdir}/valve.rc" ] && grep -E '^\s*exec\s*(default|joystick)\.cfg' "${servercfgdir}/valve.rc" > /dev/null 2>&1; then
  41. fixname="valve.rc"
  42. fn_fix_msg_start
  43. sed -i 's/^\s*exec\s*default.cfg/\/\/exec default.cfg/g' "${servercfgdir}/valve.rc" > /dev/null 2>&1
  44. sed -i 's/^\s*exec\s*joystick.cfg/\/\/exec joystick.cfg/g' "${servercfgdir}/valve.rc" > /dev/null 2>&1
  45. fn_fix_msg_end
  46. fi
  47. # Fixes: Detected engine 11 but could not load: /home/csgo/serverfiles/bin/libgcc_s.so.1: version `GCC_7.0.0' not found (required by /lib/i386-linux-gnu/libstdc++.so.6)
  48. libgccc_so="${serverfiles}/bin/libgcc_s.so.1"
  49. if [ -f "${libgccc_so}" ]; then
  50. fixname="libgcc_s.so.1 move away"
  51. fn_fix_msg_start
  52. mv "${libgccc_so}" "${libgccc_so}.bak"
  53. fn_fix_msg_end
  54. fi