fn_install_serverfiles 2.7 KB

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