fn_install_serverfiles 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/bin/bash
  2. # LGSM fn_install_serverfiles function
  3. # Author: Daniel Gibbs
  4. # Website: http://gameservermanagers.com
  5. # Version: 190515
  6. fn_steaminstallcommand(){
  7. fn_check_steamuser
  8. counter="0"
  9. while [ "${counter}" == "0" ]||[ "$(grep -wc 0x402 .fn_install_serverfiles.tmp)" -ge "1" ]||[ "$(grep -wc 0x406 .fn_install_serverfiles.tmp)" -ge "1" ]||[ "$(grep -wc 0x6 .fn_install_serverfiles.tmp)" -ge "1" ]||[ "$(grep -wc 0x106 .fn_install_serverfiles.tmp)" -ge "1" ]; do
  10. counter=$((counter+1))
  11. if [ "${counter}" -le "10" ]; then
  12. # Attempt 1-4: Standard attempt
  13. # Attempt 5-6: Validate attempt
  14. # Attempt 7-8: Validate, delete long name dir
  15. # Attempt 9-10: Validate, delete long name dir, re-download SteamCMD
  16. # Attempt 11: Failure
  17. if [ "${counter}" -ge "2" ]; then
  18. fn_printwarningnl "SteamCMD did not complete the download, retrying: Attempt ${counter}:"
  19. fi
  20. if [ "${counter}" -ge "7" ]; then
  21. echo "Removing $(find ${filesdir} -type d -print0 | grep -Ez '[^/]{30}$')"
  22. find ${filesdir} -type d -print0 | grep -Ez '[^/]{30}$' | xargs -0 rm -rf
  23. fi
  24. if [ "${counter}" -ge "9" ]; then
  25. rm -rf "${rootdir}/steamcmd"
  26. fn_check_steamcmd
  27. fi
  28. # Detects if unbuffer command is available.
  29. if [ $(command -v unbuffer) ]; then
  30. unbuffer=unbuffer
  31. fi
  32. if [ "${counter}" -le "4" ]; then
  33. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit |tee .fn_install_serverfiles.tmp
  34. elif [ "${counter}" -ge "5" ]; then
  35. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" -validate +quit |tee .fn_install_serverfiles.tmp
  36. fi
  37. elif [ "${counter}" -ge "11" ]; then
  38. fn_printfailurenl "SteamCMD did not complete the download, too many retrys"
  39. break
  40. fi
  41. done
  42. # Goldsource servers commonly fail to download all the server files required.
  43. # Validating a few of times may reduce the chance of this issue.
  44. if [ "${engine}" == "goldsource" ]; then
  45. counter="0"
  46. while [ "${counter}" -le "4" ]; do
  47. counter=$((counter+1))
  48. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" -validate +quit |tee .fn_install_serverfiles.tmp
  49. done
  50. fi
  51. rm -f .fn_install_serverfiles.tmp
  52. }
  53. echo ""
  54. echo "Installing ${gamename} Server"
  55. echo "================================="
  56. sleep 1
  57. mkdir -pv "${filesdir}"
  58. cd "${rootdir}/steamcmd"
  59. fn_steaminstallcommand
  60. if [ -z "${autoinstall}" ]; then
  61. echo ""
  62. echo "================================="
  63. while true; do
  64. read -p "Was the install successful? [y/N]" yn
  65. case $yn in
  66. [Yy]* ) break;;
  67. [Nn]* ) fn_install_retry;;
  68. * ) echo "Please answer yes or no.";;
  69. esac
  70. done
  71. fi