install_server_files.sh 4.8 KB

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