install_server_files.sh 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #!/bin/bash
  2. # LGSM install_server_files.sh function
  3. # Author: Daniel Gibbs
  4. # Website: https://gameservermanagers.com
  5. local commandnane="INSTALL"
  6. local commandaction="Install"
  7. local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  8. fn_install_server_files(){
  9. if [ "${gamename}" == "Unreal Tournament 99" ]; then
  10. 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"
  11. elif [ "${gamename}" == "Unreal Tournament 2004" ]; then
  12. 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"
  13. elif [ "${gamename}" == "GoldenEye: Source" ]; then
  14. 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"
  15. fi
  16. fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}"
  17. fn_dl_extract "${filedir}" "${filename}" "${filesdir}"
  18. }
  19. fn_install_server_files_steamcmd(){
  20. counter="0"
  21. while [ "${counter}" == "0" ]||[ "${exitcode}" != "0" ]; do
  22. counter=$((counter+1))
  23. cd "${rootdir}/steamcmd"
  24. if [ "${counter}" -le "10" ]; then
  25. # Attempt 1-4: Standard attempt
  26. # Attempt 5-6: Validate attempt
  27. # Attempt 7-8: Validate, delete long name dir
  28. # Attempt 9-10: Validate, delete long name dir, re-download SteamCMD
  29. # Attempt 11: Failure
  30. if [ "${counter}" -ge "2" ]; then
  31. fn_print_warning_nl "SteamCMD did not complete the download, retrying: Attempt ${counter}"
  32. fn_script_log "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 stdbuf) ]; then
  44. unbuffer="stdbuf -i0 -o0 -e0"
  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}" ${branch} +quit
  49. local exitcode=$?
  50. else
  51. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit
  52. local exitcode=$?
  53. fi
  54. elif [ "${counter}" -ge "5" ]; then
  55. if [ "${engine}" == "goldsource" ]; then
  56. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" ${branch} -validate +quit
  57. local exitcode=$?
  58. else
  59. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" -validate +quit
  60. local exitcode=$?
  61. fi
  62. fi
  63. elif [ "${counter}" -ge "11" ]; then
  64. fn_print_failure_nl "SteamCMD did not complete the download, too many retrys"
  65. fn_script_log "SteamCMD did not complete the download, too many retrys"
  66. break
  67. fi
  68. done
  69. # Goldsource servers commonly fail to download all the server files required.
  70. # Validating a few of times may reduce the chance of this issue.
  71. if [ "${engine}" == "goldsource" ]; then
  72. 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."
  73. counter="0"
  74. while [ "${counter}" -le "4" ]; do
  75. counter=$((counter+1))
  76. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" -validate +quit
  77. local exitcode=$?
  78. done
  79. fi
  80. }
  81. echo ""
  82. echo "Installing ${gamename} Server"
  83. echo "================================="
  84. sleep 1
  85. if [ "${gamename}" == "Teamspeak 3" ]; then
  86. update_ts3.sh
  87. elif [ -z "${appid}" ]||[ "${gamename}" == "GoldenEye: Source" ]; then
  88. fn_install_server_files
  89. fi
  90. if [ -n "${appid}" ]; then
  91. fn_install_server_files_steamcmd
  92. fi
  93. if [ -z "${autoinstall}" ]; then
  94. echo ""
  95. echo "================================="
  96. while true; do
  97. read -e -i "y" -p "Was the install successful? [Y/n]" yn
  98. case $yn in
  99. [Yy]* ) break;;
  100. [Nn]* ) install_retry.sh;;
  101. * ) echo "Please answer yes or no.";;
  102. esac
  103. done
  104. fi