install_server_files.sh 5.8 KB

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