install_server_files.sh 5.3 KB

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