install_server_files.sh 4.4 KB

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