fn_install_serverfiles 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/bin/bash
  2. # LGSM fn_install_serverfiles function
  3. # Author: Daniel Gibbs
  4. # Website: http://gameservermanagers.com
  5. # Version: 051115
  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. if [ "${engine}" == "goldsource" ]; then
  35. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" +quit |tee .fn_install_serverfiles.tmp
  36. else
  37. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit |tee .fn_install_serverfiles.tmp
  38. fi
  39. elif [ "${counter}" -ge "5" ]; then
  40. if [ "${engine}" == "goldsource" ]; then
  41. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" -validate +quit |tee .fn_install_serverfiles.tmp
  42. else
  43. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" -validate +quit |tee .fn_install_serverfiles.tmp
  44. fi
  45. fi
  46. elif [ "${counter}" -ge "11" ]; then
  47. fn_printfailurenl "SteamCMD did not complete the download, too many retrys"
  48. break
  49. fi
  50. done
  51. # Goldsource servers commonly fail to download all the server files required.
  52. # Validating a few of times may reduce the chance of this issue.
  53. if [ "${engine}" == "goldsource" ]; then
  54. counter="0"
  55. while [ "${counter}" -le "4" ]; do
  56. counter=$((counter+1))
  57. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" -validate +quit |tee .fn_install_serverfiles.tmp
  58. done
  59. fi
  60. rm -f .fn_install_serverfiles.tmp
  61. }
  62. echo ""
  63. echo "Installing ${gamename} Server"
  64. echo "================================="
  65. sleep 1
  66. mkdir -pv "${filesdir}"
  67. cd "${rootdir}/steamcmd"
  68. fn_steaminstallcommand
  69. if [ -z "${autoinstall}" ]; then
  70. echo ""
  71. echo "================================="
  72. while true; do
  73. read -e -i "y" -p "Was the install successful? [Y/n]" yn
  74. case $yn in
  75. [Yy]* ) break;;
  76. [Nn]* ) fn_install_retry;;
  77. * ) echo "Please answer yes or no.";;
  78. esac
  79. done
  80. fi