fn_install_serverfiles 2.6 KB

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