fix_steamcmd.sh 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #!/bin/bash
  2. # LinuxGSM fix_steamcmd.sh module
  3. # Author: Daniel Gibbs
  4. # Contributors: https://linuxgsm.com/contrib
  5. # Website: https://linuxgsm.com
  6. # Description: Resolves issues with SteamCMD.
  7. moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  8. # function to simplify the steamclient.so fix
  9. # example
  10. # fn_fix_steamclient_so 32|64 (bit) "${serverfiles}/linux32/"
  11. fn_fix_steamclient_so() {
  12. # $1 type of fix 32 or 64 as possible values
  13. # $2 as destination where the lib will be copied to
  14. if [ "$1" == "32" ]; then
  15. # steamclient.so x86 fix.
  16. if [ ! -f "${2}/steamclient.so" ]; then
  17. fixname="steamclient.so x86"
  18. fn_fix_msg_start
  19. if [ ! -d "${2}" ]; then
  20. mkdir -p "${2}"
  21. fi
  22. if [ -f "${HOME}/.steam/steamcmd/linux32/steamclient.so" ]; then
  23. cp "${HOME}/.steam/steamcmd/linux32/steamclient.so" "${2}/steamclient.so"
  24. elif [ -f "${steamcmddir}/linux32/steamclient.so" ]; then
  25. cp "${steamcmddir}/linux32/steamclient.so" "${2}/steamclient.so"
  26. elif [ -f "${HOME}/.local/share/Steam/steamcmd/linux32/steamclient.so" ]; then
  27. cp "${HOME}/.local/share/Steam/steamcmd/linux32/steamclient.so" "${2}/steamclient.so"
  28. fi
  29. fn_fix_msg_end
  30. fi
  31. elif [ "$1" == "64" ]; then
  32. # steamclient.so x86_64 fix.
  33. if [ ! -f "${2}/steamclient.so" ]; then
  34. fixname="steamclient.so x86_64"
  35. fn_fix_msg_start
  36. if [ ! -d "${2}" ]; then
  37. mkdir -p "${2}"
  38. fi
  39. if [ -f "${HOME}/.steam/steamcmd/linux64/steamclient.so" ]; then
  40. cp "${HOME}/.steam/steamcmd/linux64/steamclient.so" "${2}/steamclient.so"
  41. elif [ -f "${steamcmddir}/linux64/steamclient.so" ]; then
  42. cp "${steamcmddir}/linux64/steamclient.so" "${2}/steamclient.so"
  43. elif [ -f "${HOME}/.local/share/Steam/steamcmd/linux64/steamclient.so" ]; then
  44. cp "${HOME}/.local/share/Steam/steamcmd/linux64/steamclient.so" "${2}/steamclient.so"
  45. fi
  46. fn_fix_msg_end
  47. fi
  48. fi
  49. }
  50. # Helps fix: [S_API FAIL] SteamAPI_Init() failed; unable to locate a running instance of Steam,or a local steamclient.so.
  51. steamsdk64="${HOME}/.steam/sdk64"
  52. steamclientsdk64="${steamsdk64}/steamclient.so"
  53. # remove any old unlinked versions of steamclient.so
  54. if [ -f "${steamclientsdk64}" ]; then
  55. if [ "$(stat -c '%h' "${steamclientsdk64}")" -eq 1 ]; then
  56. fixname="steamclient.so sdk64 - remove old file"
  57. fn_fix_msg_start
  58. rm -f "${steamclientsdk64}"
  59. fn_fix_msg_end
  60. fi
  61. fi
  62. # place new hardlink for the file to the disk
  63. if [ ! -f "${steamclientsdk64}" ]; then
  64. fixname="steamclient.so sdk64 hardlink"
  65. fn_fix_msg_start
  66. if [ ! -d "${steamsdk64}" ]; then
  67. mkdir -p "${steamsdk64}"
  68. fi
  69. if [ -f "${HOME}/.steam/steamcmd/linux64/steamclient.so" ]; then
  70. ln "${HOME}/.steam/steamcmd/linux64/steamclient.so" "${steamclientsdk64}"
  71. elif [ -f "${steamcmddir}/linux64/steamclient.so" ]; then
  72. ln "${steamcmddir}/linux64/steamclient.so" "${steamclientsdk64}"
  73. elif [ -f "${HOME}/.local/share/Steam/steamcmd/linux64/steamclient.so" ]; then
  74. ln "${HOME}/.local/share/Steam/steamcmd/linux64/steamclient.so" "${steamclientsdk64}"
  75. else
  76. fn_print_fail_nl "Could not copy any steamclient.so 64bit for the gameserver"
  77. fi
  78. fn_fix_msg_end
  79. fi
  80. # Helps fix: [S_API FAIL] SteamAPI_Init() failed; unable to locate a running instance of Steam,or a local steamclient.so.
  81. steamsdk32="${HOME}/.steam/sdk32"
  82. steamclientsdk32="${HOME}/.steam/sdk32/steamclient.so"
  83. if [ -f "${steamclientsdk32}" ]; then
  84. if [ " $(stat -c '%h' "${steamclientsdk32}")" -eq 1 ]; then
  85. fixname="steamclient.so sdk32 - remove old file"
  86. fn_fix_msg_start
  87. rm -f "${steamclientsdk32}"
  88. fn_fix_msg_end
  89. fi
  90. fi
  91. # place new hardlink for the file to the disk
  92. if [ ! -f "${steamclientsdk32}" ]; then
  93. fixname="steamclient.so sdk32 link"
  94. fn_fix_msg_start
  95. if [ ! -d "${steamsdk32}" ]; then
  96. mkdir -p "${steamsdk32}"
  97. fi
  98. if [ -f "${HOME}/.steam/steamcmd/linux32/steamclient.so" ]; then
  99. ln "${HOME}/.steam/steamcmd/linux32/steamclient.so" "${steamclientsdk32}"
  100. elif [ -f "${steamcmddir}/linux32/steamclient.so" ]; then
  101. ln "${steamcmddir}/linux32/steamclient.so" "${steamclientsdk32}"
  102. elif [ -f "${HOME}/.local/share/Steam/steamcmd/linux32/steamclient.so" ]; then
  103. ln "${HOME}/.local/share/Steam/steamcmd/linux32/steamclient.so" "${steamclientsdk32}"
  104. else
  105. fn_print_fail_nl "Could not copy any steamclient.so 32bit for the gameserver"
  106. fi
  107. fn_fix_msg_end
  108. fi
  109. # steamclient.so fixes
  110. if [ "${shortname}" == "bo" ]; then
  111. fn_fix_steamclient_so "32" "${serverfiles}/BODS_Data/Plugins/x86"
  112. fn_fix_steamclient_so "64" "${serverfiles}/BODS_Data/Plugins/x86_64"
  113. elif [ "${shortname}" == "cmw" ]; then
  114. fn_fix_steamclient_so "32" "${executabledir}/lib"
  115. elif [ "${shortname}" == "cs" ]; then
  116. fn_fix_steamclient_so "32" "${serverfiles}"
  117. elif [ "${shortname}" == "col" ]; then
  118. fn_fix_steamclient_so "64" "${serverfiles}"
  119. elif [ "${shortname}" == "ins" ]; then
  120. fn_fix_steamclient_so "32" "${serverfiles}/bin"
  121. elif [ "${shortname}" == "pz" ]; then
  122. fn_fix_steamclient_so "32" "${serverfiles}/linux32"
  123. fn_fix_steamclient_so "64" "${serverfiles}/linux64"
  124. elif [ "${shortname}" == "pvr" ]; then
  125. fn_fix_steamclient_so "64" "${executabledir}"
  126. elif [ "${shortname}" == "ss3" ]; then
  127. fn_fix_steamclient_so "32" "${serverfiles}/Bin"
  128. elif [ "${shortname}" == "tu" ]; then
  129. fn_fix_steamclient_so "64" "${executabledir}"
  130. elif [ "${shortname}" == "unt" ]; then
  131. fn_fix_steamclient_so "64" "${serverfiles}"
  132. elif [ "${shortname}" == "wurm" ]; then
  133. fn_fix_steamclient_so "64" "${serverfiles}/nativelibs"
  134. fi