install_server_files.sh 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #!/bin/bash
  2. # LGSM install_server_files.sh function
  3. # Author: Daniel Gibbs
  4. # Website: http://gameservermanagers.com
  5. lgsm_version="270216"
  6. fn_install_server_files(){
  7. if [ "${gamename}" == "Unreal Tournament 99" ]; then
  8. fileurl="http://gameservermanagers.com/files/UnrealTournament99/ut99-server-451-ultimate-linux.tar.bz2"; filedir="${lgsmdir}/tmp"; filename="ut99-server-451-ultimate-linux.tar.bz2"; run="norun"; force="noforce"; md5="e623fdff5ed600a9bfccab852e18d34d"
  9. elif [ "${gamename}" == "Unreal Tournament 2004" ]; then
  10. fileurl="http://gameservermanagers.com/files/UnrealTournament2004/ut2004-server-3339-ultimate-linux.tar.bz2"; filedir="${lgsmdir}/tmp"; filename="ut2004-server-3339-ultimate-linux.tar.bz2"; run="norun"; force="noforce"; md5="e623fdff5ed600a9bfccab852e18d34d"
  11. fi
  12. fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${run}" "${force}" "${md5}"
  13. fn_dl_extract "${filedir}" "${filename}" "${filesdir}"
  14. }
  15. fn_install_server_files_steamcmd(){
  16. check.sh
  17. mkdir -pv "${filesdir}"
  18. counter="0"
  19. 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
  20. counter=$((counter+1))
  21. cd "${rootdir}/steamcmd"
  22. if [ "${counter}" -le "10" ]; then
  23. # Attempt 1-4: Standard attempt
  24. # Attempt 5-6: Validate attempt
  25. # Attempt 7-8: Validate, delete long name dir
  26. # Attempt 9-10: Validate, delete long name dir, re-download SteamCMD
  27. # Attempt 11: Failure
  28. if [ "${counter}" -ge "2" ]; then
  29. fn_printwarningnl "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. fi
  43. if [ "${counter}" -le "4" ]; then
  44. if [ "${engine}" == "goldsource" ]; then
  45. ${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
  46. else
  47. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit |tee .install_serverfiles.sh.tmp
  48. fi
  49. elif [ "${counter}" -ge "5" ]; then
  50. if [ "${engine}" == "goldsource" ]; then
  51. ${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
  52. else
  53. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" -validate +quit |tee .install_serverfiles.sh.tmp
  54. fi
  55. fi
  56. elif [ "${counter}" -ge "11" ]; then
  57. fn_printfailurenl "SteamCMD did not complete the download, too many retrys"
  58. break
  59. fi
  60. done
  61. # Goldsource servers commonly fail to download all the server files required.
  62. # Validating a few of times may reduce the chance of this issue.
  63. if [ "${engine}" == "goldsource" ]; then
  64. counter="0"
  65. while [ "${counter}" -le "4" ]; do
  66. counter=$((counter+1))
  67. ${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
  68. done
  69. fi
  70. rm -f .install_serverfiles.sh.tmp
  71. }
  72. echo ""
  73. echo "Installing ${gamename} Server"
  74. echo "================================="
  75. sleep 1
  76. if [ -n "${appid}" ]; then
  77. fn_install_server_files_steamcmd
  78. fi
  79. if [ -z "${appid}" ]||[ "${gamename}" == "GoldenEye: Source" ]; then
  80. fn_install_server_files
  81. fi
  82. if [ -z "${autoinstall}" ]; then
  83. echo ""
  84. echo "================================="
  85. while true; do
  86. read -e -i "y" -p "Was the install successful? [Y/n]" yn
  87. case $yn in
  88. [Yy]* ) break;;
  89. [Nn]* ) install_retry.sh;;
  90. * ) echo "Please answer yes or no.";;
  91. esac
  92. done
  93. fi