install_serverfiles.sh 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/bin/bash
  2. # LGSM finstall_serverfiles.sh function
  3. # Author: Daniel Gibbs
  4. # Website: http://gameservermanagers.com
  5. lgsm_version="061115"
  6. fn_steaminstallcommand(){
  7. check_steamuser.sh
  8. counter="0"
  9. while [ "${counter}" == "0" ]||[ "$(grep -wc 0x402 .finstall_serverfiles.sh.tmp)" -ge "1" ]||[ "$(grep -wc 0x406 .finstall_serverfiles.sh.tmp)" -ge "1" ]||[ "$(grep -wc 0x6 .finstall_serverfiles.sh.tmp)" -ge "1" ]||[ "$(grep -wc 0x106 .finstall_serverfiles.sh.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. check_steamcmd.sh
  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 .finstall_serverfiles.sh.tmp
  36. else
  37. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit |tee .finstall_serverfiles.sh.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 .finstall_serverfiles.sh.tmp
  42. else
  43. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" -validate +quit |tee .finstall_serverfiles.sh.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 .finstall_serverfiles.sh.tmp
  58. done
  59. fi
  60. rm -f .finstall_serverfiles.sh.tmp
  61. }
  62. echo ""
  63. echo "Installing ${gamename} Server"
  64. echo "================================="
  65. sleep 1
  66. mkdir -pv "${filesdir}"
  67. fn_steaminstallcommand
  68. if [ -z "${autoinstall}" ]; then
  69. echo ""
  70. echo "================================="
  71. while true; do
  72. read -e -i "y" -p "Was the install successful? [Y/n]" yn
  73. case $yn in
  74. [Yy]* ) break;;
  75. [Nn]* ) install_retry.sh;;
  76. * ) echo "Please answer yes or no.";;
  77. esac
  78. done
  79. fi