fn_install_serverfiles 2.5 KB

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