install_server_files.sh 6.6 KB

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