install_server_files.sh 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #!/bin/bash
  2. # LGSM install_server_files.sh function
  3. # Author: Daniel Gibbs
  4. # Website: http://gameservermanagers.com
  5. lgsm_version="270216"
  6. local modulename="Install"
  7. fn_install_server_files(){
  8. if [ "${gamename}" == "Unreal Tournament 99" ]; then
  9. fileurl="http://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="http://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. 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
  46. local exitcode=$?
  47. else
  48. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit
  49. local exitcode=$?
  50. fi
  51. elif [ "${counter}" -ge "5" ]; then
  52. if [ "${engine}" == "goldsource" ]; then
  53. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" -validate +quit
  54. local exitcode=$?
  55. else
  56. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" -validate +quit
  57. local exitcode=$?
  58. fi
  59. fi
  60. elif [ "${counter}" -ge "11" ]; then
  61. fn_print_failure_nl "SteamCMD did not complete the download, too many retrys"
  62. fn_scriptlog "SteamCMD did not complete the download, too many retrys"
  63. break
  64. fi
  65. done
  66. # Goldsource servers commonly fail to download all the server files required.
  67. # Validating a few of times may reduce the chance of this issue.
  68. if [ "${engine}" == "goldsource" ]; then
  69. 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."
  70. counter="0"
  71. while [ "${counter}" -le "4" ]; do
  72. counter=$((counter+1))
  73. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" -validate +quit
  74. local exitcode=$?
  75. done
  76. fi
  77. }
  78. echo ""
  79. echo "Installing ${gamename} Server"
  80. echo "================================="
  81. sleep 1
  82. if [ -n "${appid}" ]; then
  83. fn_install_server_files_steamcmd
  84. fi
  85. if [ -z "${appid}" ]||[ "${gamename}" == "GoldenEye: Source" ]; then
  86. fn_install_server_files
  87. fi
  88. if [ -z "${autoinstall}" ]; then
  89. echo ""
  90. echo "================================="
  91. while true; do
  92. read -e -i "y" -p "Was the install successful? [Y/n]" yn
  93. case $yn in
  94. [Yy]* ) break;;
  95. [Nn]* ) install_retry.sh;;
  96. * ) echo "Please answer yes or no.";;
  97. esac
  98. done
  99. fi