install_server_files.sh 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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}" == "Battlefield: 1942" ]; then
  11. fileurl="http://files.gameservermanagers.com/BattleField1942/bf1942_lnxded-1.61-hacked-to-1.612.full.tar.bz2"; filedir="${tmpdir}"; filename="bf1942_lnxded-1.61-hacked-to-1.612.full.tar.bz2"; executecmd="noexecute" run="norun"; force="noforce"; md5="a86a5d3cd64ca59abcc9bb9f777c2e5d"
  12. elif [ "${gamename}" == "Call of Duty" ]; then
  13. fileurl="http://files.gameservermanagers.com/CallOfDuty/cod-lnxded-1.5b-full.tar.bz2"; filedir="${tmpdir}"; filename="cod-lnxded-1.5-large.tar.bz2"; executecmd="noexecute" run="norun"; force="noforce"; md5="19629895a4cf6fd8f6d1ee198b5304cd"
  14. elif [ "${gamename}" == "Call of Duty: United Offensive" ]; then
  15. fileurl="http://files.gameservermanagers.com/CallOfDutyUnitedOffensive/coduo-lnxded-1.51b-full.tar.bz2"; filedir="${tmpdir}"; filename="coduo-lnxded-1.51b-full.tar.bz2"; executecmd="noexecute" run="norun"; force="noforce"; md5="f1804ef13036e2b4ab535db000b19e97"
  16. elif [ "${gamename}" == "Call of Duty 2" ]; then
  17. fileurl="http://files.gameservermanagers.com/CallOfDuty2/cod2-lnxded-1.3-full.tar.bz2"; filedir="${tmpdir}"; filename="cod2-lnxded-1.3-full.tar.bz2"; executecmd="noexecute" run="norun"; force="noforce"; md5="078128f83d06dc3d7699428dc2870214"
  18. elif [ "${gamename}" == "Call of Duty 4" ]; then
  19. fileurl="http://files.gameservermanagers.com/CallOfDuty4/cod4x18_dedrun.tar.bz2"; filedir="${tmpdir}"; filename="cod4x18_dedrun.tar.bz2"; executecmd="noexecute" run="norun"; force="noforce"; md5="bebdfc1755626462bdaad49f6f926c08"
  20. elif [ "${gamename}" == "Call of Duty: World at War" ]; then
  21. fileurl="http://files.gameservermanagers.com/CallOfDutyWorldAtWar/codwaw-lnxded-1.7-full.tar.bz2"; filedir="${tmpdir}"; filename="codwaw-lnxded-1.7-full.tar.bz2"; executecmd="noexecute" run="norun"; force="noforce"; md5="0489697ff3bf678c109bfb377d1b7895"
  22. elif [ "${gamename}" == "GoldenEye: Source" ]; then
  23. fileurl="http://files.gameservermanagers.com/GoldenEyeSource/GoldenEye_Source_v5.0.1_full_server_linux.tar.bz2"; filedir="${tmpdir}"; filename="GoldenEye_Source_v5.0.1_server_full_Linux.tar.bz2"; executecmd="noexecute" run="norun"; force="noforce"; md5="ea227a150300abe346e757380325f84c"
  24. elif [ "${gamename}" == "Quake 2" ]; then
  25. fileurl="http://files.gameservermanagers.com/Quake2/quake2-3.20-glibc-i386-full-linux2.0.tar.bz2"; filedir="${lgsmdir}/tmp"; filename="quake2-3.20-glibc-i386-full-linux2.0.tar.bz2"; executecmd="noexecute" run="norun"; force="noforce"; md5="0b8c7e2d51f40b56b328c69e986e7c5f"
  26. elif [ "${gamename}" == "Quake 3: Arena" ]; then
  27. fileurl="http://files.gameservermanagers.com/Quake3/quake3-1.32c-x86-full-linux.tar.bz2"; filedir="${lgsmdir}/tmp"; filename="quake3-1.32c-x86-full-linux.tar.bz2"; executecmd="noexecute" run="norun"; force="noforce"; md5="fd7258d827474f67663dda297bff4306"
  28. elif [ "${gamename}" == "QuakeWorld" ]; then
  29. fileurl="http://files.gameservermanagers.com/QuakeWorld/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"
  30. elif [ "${gamename}" == "Unreal Tournament 2004" ]; then
  31. fileurl="http://files.gameservermanagers.com/UnrealTournament2004/ut2004-server-3339-ultimate-linux.tar.bz2"; filedir="${tmpdir}"; filename="ut2004-server-3339-ultimate-linux.tar.bz2"; executecmd="noexecute" run="norun"; force="noforce"; md5="67c5e2cd9c2a4b04f163962ee41eff54"
  32. elif [ "${gamename}" == "Unreal Tournament 99" ]; then
  33. fileurl="http://files.gameservermanagers.com/UnrealTournament99/ut99-server-451-ultimate-linux.tar.bz2"; filedir="${tmpdir}"; filename="ut99-server-451-ultimate-linux.tar.bz2"; executecmd="noexecute" run="norun"; force="noforce"; md5="49cb24d0550ff6ddeaba6007045c6edd"
  34. elif [ "${gamename}" == "Unreal Tournament" ]; then
  35. fileurl="http://files.gameservermanagers.com/UnrealTournament/UnrealTournament-Server-XAN-3045522-Linux.zip"; filedir="${tmpdir}"; filename="UnrealTournament-Server-XAN-3045522-Linux.zip"; executecmd="noexecute" run="norun"; force="noforce"; md5="553fed5645a9fc623e92563049bf79f6"
  36. elif [ "${gamename}" == "Unreal Tournament 3" ]; then
  37. fileurl="http://files.gameservermanagers.com/UnrealTournament3/UT3-linux-server-2.1.tar.bz2"; filedir="${tmpdir}"; filename="UT3-linux-server-2.1.tar.bz2"; executecmd="noexecute" run="norun"; force="noforce"; md5="2527437b46f1b47f20228d27d72395a6"
  38. elif [ "${gamename}" == "Wolfenstein: Enemy Territory" ]; then
  39. fileurl="http://files.gameservermanagers.com/WolfensteinEnemyTerritory/enemy-territory.260b.tar.bz2"; filedir="${tmpdir}"; filename="enemy-territory.260b.tar.bz2"; executecmd="noexecute" run="norun"; force="noforce"; md5="f833f514bfcdd46b42c111f83350c5a7"
  40. elif [ "${gamename}" == "Multi Theft Auto" ]; then
  41. fileurl="https://linux.mtasa.com/dl/153/multitheftauto_linux_x64-1.5.3.tar.gz"; filedir="${tempdir}"; filename="multitheftauto_linux_x64-1.5.3.tar.gz"; executecmd="noexecute" run="norun"; force="noforce"; md5="77caf91fe280877a8d21f8046d5f42ba"
  42. fi
  43. fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}"
  44. fn_dl_extract "${filedir}" "${filename}" "${filesdir}"
  45. }
  46. fn_install_server_files_steamcmd(){
  47. counter="0"
  48. while [ "${counter}" == "0" ]||[ "${exitcode}" != "0" ]; do
  49. counter=$((counter+1))
  50. cd "${rootdir}/steamcmd"
  51. if [ "${counter}" -le "10" ]; then
  52. # Attempt 1-4: Standard attempt
  53. # Attempt 5-6: Validate attempt
  54. # Attempt 7-8: Validate, delete long name dir
  55. # Attempt 9-10: Validate, delete long name dir, re-download SteamCMD
  56. # Attempt 11: Failure
  57. if [ "${counter}" -ge "2" ]; then
  58. fn_print_warning_nl "SteamCMD did not complete the download, retrying: Attempt ${counter}"
  59. fn_script_log "SteamCMD did not complete the download, retrying: Attempt ${counter}"
  60. fi
  61. if [ "${counter}" -ge "7" ]; then
  62. echo "Removing $(find ${filesdir} -type d -print0 | grep -Ez '[^/]{30}$')"
  63. find ${filesdir} -type d -print0 | grep -Ez '[^/]{30}$' | xargs -0 rm -rf
  64. fi
  65. if [ "${counter}" -ge "9" ]; then
  66. rm -rf "${rootdir}/steamcmd"
  67. check_steamcmd.sh
  68. fi
  69. # Detects if unbuffer command is available for 32 bit distributions only.
  70. info_distro.sh
  71. if [ $(command -v stdbuf) ]&&[ "${arch}" != "x86_64" ]; then
  72. unbuffer="stdbuf -i0 -o0 -e0"
  73. fi
  74. if [ "${counter}" -le "4" ]; then
  75. if [ "${engine}" == "goldsource" ]; then
  76. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" ${branch} +quit
  77. local exitcode=$?
  78. else
  79. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" ${branch} +quit
  80. local exitcode=$?
  81. fi
  82. elif [ "${counter}" -ge "5" ]; then
  83. if [ "${engine}" == "goldsource" ]; then
  84. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" ${branch} -validate +quit
  85. local exitcode=$?
  86. else
  87. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" ${branch} -validate +quit
  88. local exitcode=$?
  89. fi
  90. fi
  91. elif [ "${counter}" -ge "11" ]; then
  92. fn_print_failure_nl "SteamCMD did not complete the download, too many retrys"
  93. fn_script_log "SteamCMD did not complete the download, too many retrys"
  94. break
  95. fi
  96. done
  97. # Goldsource servers commonly fail to download all the server files required.
  98. # Validating a few of times may reduce the chance of this issue.
  99. if [ "${engine}" == "goldsource" ]; then
  100. 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."
  101. counter="0"
  102. while [ "${counter}" -le "4" ]; do
  103. counter=$((counter+1))
  104. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" ${branch} -validate +quit
  105. local exitcode=$?
  106. done
  107. fi
  108. }
  109. echo ""
  110. echo "Installing ${gamename} Server"
  111. echo "================================="
  112. sleep 1
  113. if [ -n "${appid}" ]; then
  114. fn_install_server_files_steamcmd
  115. fi
  116. if [ "${gamename}" == "TeamSpeak 3" ]; then
  117. update_ts3.sh
  118. elif [ "${gamename}" == "Minecraft" ]; then
  119. update_minecraft.sh
  120. install_minecraft_eula.sh
  121. elif [ "${gamename}" == "Mumble" ]; then
  122. update_mumble.sh
  123. elif [ -z "${appid}" ]||[ "${gamename}" == "GoldenEye: Source" ]; then
  124. fn_install_server_files
  125. fi
  126. if [ -z "${autoinstall}" ]; then
  127. echo ""
  128. echo "================================="
  129. while true; do
  130. read -e -i "y" -p "Was the install successful? [Y/n]" yn
  131. case $yn in
  132. [Yy]* ) break;;
  133. [Nn]* ) install_retry.sh;;
  134. * ) echo "Please answer yes or no.";;
  135. esac
  136. done
  137. fi