install_server_files.sh 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #!/bin/bash
  2. # LGSM install_server_files.sh function
  3. # Author: Daniel Gibbs
  4. # Website: http://gameservermanagers.com
  5. lgsm_version="050216"
  6. fn_install_server_files(){
  7. if [ "${gamename}" == "Unreal Tournament 99" ]; then
  8. fileurl="http://gameservermanagers.com/files/ut-server-451-complete.tar.bz2"; filedir="${lgsmdir}/tmp"; filename="ut-server-451-complete.tar.bz2"; run="norun"; force="noforce"; md5="e623fdff5ed600a9bfccab852e18d34d"
  9. fi
  10. fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${run}" "${force}" "${md5}"
  11. fn_dl_extract "${filedir}" "${filename}" "${filesdir}"
  12. }
  13. #!/bin/bash
  14. # LGSM install_serverfiles.sh function
  15. # Author: Daniel Gibbs
  16. # Website: http://gameservermanagers.com
  17. lgsm_version="271215"
  18. fn_install_server_files_steamcmd(){
  19. check.sh
  20. mkdir -pv "${filesdir}"
  21. counter="0"
  22. while [ "${counter}" == "0" ]||[ "$(grep -wc 0x402 .install_serverfiles.sh.tmp)" -ge "1" ]||[ "$(grep -wc 0x406 .install_serverfiles.sh.tmp)" -ge "1" ]||[ "$(grep -wc 0x6 .install_serverfiles.sh.tmp)" -ge "1" ]||[ "$(grep -wc 0x106 .install_serverfiles.sh.tmp)" -ge "1" ]; do
  23. counter=$((counter+1))
  24. cd "${rootdir}/steamcmd"
  25. if [ "${counter}" -le "10" ]; then
  26. # Attempt 1-4: Standard attempt
  27. # Attempt 5-6: Validate attempt
  28. # Attempt 7-8: Validate, delete long name dir
  29. # Attempt 9-10: Validate, delete long name dir, re-download SteamCMD
  30. # Attempt 11: Failure
  31. if [ "${counter}" -ge "2" ]; then
  32. fn_printwarningnl "SteamCMD did not complete the download, retrying: Attempt ${counter}:"
  33. fi
  34. if [ "${counter}" -ge "7" ]; then
  35. echo "Removing $(find ${filesdir} -type d -print0 | grep -Ez '[^/]{30}$')"
  36. find ${filesdir} -type d -print0 | grep -Ez '[^/]{30}$' | xargs -0 rm -rf
  37. fi
  38. if [ "${counter}" -ge "9" ]; then
  39. rm -rf "${rootdir}/steamcmd"
  40. check_steamcmd.sh
  41. fi
  42. # Detects if unbuffer command is available.
  43. if [ $(command -v unbuffer) ]; then
  44. unbuffer=unbuffer
  45. fi
  46. if [ "${counter}" -le "4" ]; then
  47. if [ "${engine}" == "goldsource" ]; then
  48. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" +quit |tee .install_serverfiles.sh.tmp
  49. else
  50. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit |tee .install_serverfiles.sh.tmp
  51. fi
  52. elif [ "${counter}" -ge "5" ]; then
  53. if [ "${engine}" == "goldsource" ]; then
  54. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" -validate +quit |tee .install_serverfiles.sh.tmp
  55. else
  56. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" -validate +quit |tee .install_serverfiles.sh.tmp
  57. fi
  58. fi
  59. elif [ "${counter}" -ge "11" ]; then
  60. fn_printfailurenl "SteamCMD did not complete the download, too many retrys"
  61. break
  62. fi
  63. done
  64. # Goldsource servers commonly fail to download all the server files required.
  65. # Validating a few of times may reduce the chance of this issue.
  66. if [ "${engine}" == "goldsource" ]; then
  67. counter="0"
  68. while [ "${counter}" -le "4" ]; do
  69. counter=$((counter+1))
  70. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" -validate +quit |tee .install_serverfiles.sh.tmp
  71. done
  72. fi
  73. rm -f .install_serverfiles.sh.tmp
  74. }
  75. echo ""
  76. echo "Installing ${gamename} Server"
  77. echo "================================="
  78. sleep 1
  79. if [ -n "${appid}" ]; then
  80. fn_install_server_files_steamcmd
  81. fi
  82. if [ -z "${appid}" ]||[ "${gamename}" == "GoldenEye: Source" ]; then
  83. fn_install_server_files
  84. fi
  85. if [ -z "${autoinstall}" ]; then
  86. echo ""
  87. echo "================================="
  88. while true; do
  89. read -e -i "y" -p "Was the install successful? [Y/n]" yn
  90. case $yn in
  91. [Yy]* ) break;;
  92. [Nn]* ) install_retry.sh;;
  93. * ) echo "Please answer yes or no.";;
  94. esac
  95. done
  96. fi