install_server_files.sh 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. #!/bin/bash
  2. # LinuxGSM install_server_files.sh function
  3. # Author: Daniel Gibbs
  4. # Website: https://linuxgsm.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. remote_fileurl="http://files.linuxgsm.com/BattleField1942/bf1942_lnxded-1.61-hacked-to-1.612.full.tar.bz2"; local_filedir="${tmpdir}"; local_filename="bf1942_lnxded-1.61-hacked-to-1.612.full.tar.bz2"; chmodx="nochmodx" run="norun"; force="noforce"; md5="a86a5d3cd64ca59abcc9bb9f777c2e5d"
  12. elif [ "${gamename}" == "BrainBread" ]; then
  13. remote_fileurl="https://files.linuxgsm.com/BrainBread/brainbread-v1.2-linuxserver.tar.bz2"; local_filedir="${tmpdir}"; local_filename="brainbread-v1.2-linuxserver.tar.bz2"; chmodx="nochmodx" run="norun"; force="noforce"; md5="5c729a7e9eecfa81b71a6a1f7267f0fd"
  14. elif [ "${gamename}" == "Call of Duty" ]; then
  15. remote_fileurl="http://files.linuxgsm.com/CallOfDuty/cod-lnxded-1.5b-full.tar.bz2"; local_filedir="${tmpdir}"; local_filename="cod-lnxded-1.5-large.tar.bz2"; chmodx="nochmodx" run="norun"; force="noforce"; md5="19629895a4cf6fd8f6d1ee198b5304cd"
  16. elif [ "${gamename}" == "Call of Duty: United Offensive" ]; then
  17. remote_fileurl="http://files.linuxgsm.com/CallOfDutyUnitedOffensive/coduo-lnxded-1.51b-full.tar.bz2"; local_filedir="${tmpdir}"; local_filename="coduo-lnxded-1.51b-full.tar.bz2"; chmodx="nochmodx" run="norun"; force="noforce"; md5="f1804ef13036e2b4ab535db000b19e97"
  18. elif [ "${gamename}" == "Call of Duty 2" ]; then
  19. remote_fileurl="http://files.linuxgsm.com/CallOfDuty2/cod2-lnxded-1.3-full.tar.bz2"; local_filedir="${tmpdir}"; local_filename="cod2-lnxded-1.3-full.tar.bz2"; chmodx="nochmodx" run="norun"; force="noforce"; md5="078128f83d06dc3d7699428dc2870214"
  20. elif [ "${gamename}" == "Call of Duty 4" ]; then
  21. remote_fileurl="http://files.linuxgsm.com/CallOfDuty4/cod4x18_dedrun.tar.bz2"; local_filedir="${tmpdir}"; local_filename="cod4x18_dedrun.tar.bz2"; chmodx="nochmodx" run="norun"; force="noforce"; md5="bebdfc1755626462bdaad49f6f926c08"
  22. elif [ "${gamename}" == "Call of Duty: World at War" ]; then
  23. remote_fileurl="http://files.linuxgsm.com/CallOfDutyWorldAtWar/codwaw-lnxded-1.7-full.tar.bz2"; local_filedir="${tmpdir}"; local_filename="codwaw-lnxded-1.7-full.tar.bz2"; chmodx="nochmodx" run="norun"; force="noforce"; md5="0489697ff3bf678c109bfb377d1b7895"
  24. elif [ "${shortname}" == "etl" ]; then
  25. remote_fileurl="http://files.linuxgsm.com/WolfensteinEnemyTerritory/etlegacy-v2.75-i386-et-260b.tar.bz2"; local_filedir="${tmpdir}"; local_filename="etlegacy-v2.75-i386-et-260b.tar.bz2"; chmodx="nochmodx" run="norun"; force="noforce"; md5="92d7d4c26e0a295daed78cef623eeabb"
  26. elif [ "${gamename}" == "GoldenEye: Source" ]; then
  27. remote_fileurl="http://files.linuxgsm.com/GoldenEyeSource/GoldenEye_Source_v5.0.6_full_server.tar.bz2"; local_filedir="${tmpdir}"; local_filename="GoldenEye_Source_v5.0.6_full_server.tar.bz2"; chmodx="nochmodx" run="norun"; force="noforce"; md5="c45c16293096706e8b5e2cd64a6f2931"
  28. elif [ "${gamename}" == "Quake 2" ]; then
  29. remote_fileurl="http://files.linuxgsm.com/Quake2/quake2-3.20-glibc-i386-full-linux2.0.tar.bz2"; local_filedir="${tmpdir}"; local_filename="quake2-3.20-glibc-i386-full-linux2.0.tar.bz2"; chmodx="nochmodx" run="norun"; force="noforce"; md5="0b8c7e2d51f40b56b328c69e986e7c5f"
  30. elif [ "${gamename}" == "Quake 3: Arena" ]; then
  31. remote_fileurl="http://files.linuxgsm.com/Quake3/quake3-1.32c-x86-full-linux.tar.bz2"; local_filedir="${tmpdir}"; local_filename="quake3-1.32c-x86-full-linux.tar.bz2"; chmodx="nochmodx" run="norun"; force="noforce"; md5="fd7258d827474f67663dda297bff4306"
  32. elif [ "${gamename}" == "QuakeWorld" ]; then
  33. remote_fileurl="http://files.linuxgsm.com/QuakeWorld/nquake.server.linux.083116.full.tar.bz2"; local_filedir="${tmpdir}"; local_filename="nquake.server.linux.083116.full.tar.bz2"; chmodx="nochmodx" run="norun"; force="noforce"; md5="75a409cf08d808f075e4dacdc7b21b78"
  34. elif [ "${gamename}" == "Unreal Tournament 2004" ]; then
  35. remote_fileurl="http://files.linuxgsm.com/UnrealTournament2004/ut2004-server-3369-2-ultimate-linux.tar.bz2"; local_filedir="${tmpdir}"; local_filename="ut2004-server-3369-2-ultimate-linux.tar.bz2"; chmodx="nochmodx" run="norun"; force="noforce"; md5="67c5e2cd9c2a4b04f163962ee41eff54"
  36. elif [ "${gamename}" == "Unreal Tournament 99" ]; then
  37. remote_fileurl="http://files.linuxgsm.com/UnrealTournament99/ut99-server-451-ultimate-linux.tar.bz2"; local_filedir="${tmpdir}"; local_filename="ut99-server-451-ultimate-linux.tar.bz2"; chmodx="nochmodx" run="norun"; force="noforce"; md5="49cb24d0550ff6ddeaba6007045c6edd"
  38. elif [ "${gamename}" == "Unreal Tournament" ]; then
  39. remote_fileurl="https://s3.amazonaws.com/unrealtournament/UnrealTournament-Client-XAN-3395761-Linux.zip"; local_filedir="${tmpdir}"; local_filename="UnrealTournament-Server-XAN-3395761-Linux.zip"; chmodx="noexecute" run="norun"; force="noforce"; md5="f04ad5b96865b19613303331ff4075eb"
  40. elif [ "${gamename}" == "Unreal Tournament 3" ]; then
  41. remote_fileurl="http://files.linuxgsm.com/UnrealTournament3/UT3-linux-server-2.1.tar.bz2"; local_filedir="${tmpdir}"; local_filename="UT3-linux-server-2.1.tar.bz2"; chmodx="nochmodx" run="norun"; force="noforce"; md5="2527437b46f1b47f20228d27d72395a6"
  42. elif [ "${gamename}" == "Wolfenstein: Enemy Territory" ]; then
  43. remote_fileurl="http://files.linuxgsm.com/WolfensteinEnemyTerritory/enemy-territory.260b.tar.bz2"; local_filedir="${tmpdir}"; local_filename="enemy-territory.260b.tar.bz2"; chmodx="nochmodx" run="norun"; force="noforce"; md5="f833f514bfcdd46b42c111f83350c5a7"
  44. elif [ "${gamename}" == "San Andreas Multiplayer" ]; then
  45. remote_fileurl="http://files.sa-mp.com/samp037svr_R2-1.tar.gz"; local_filedir="${tmpdir}"; local_filename="samp037svr_R2-1.tar.gz"; chmodx="nochmodx" run="norun"; force="noforce"; md5="93705e165550c97484678236749198a4"
  46. fi
  47. fn_fetch_file "${remote_fileurl}" "${local_filedir}" "${local_filename}" "${chmodx}" "${run}" "${forcedl}" "${md5}"
  48. fn_dl_extract "${local_filedir}" "${local_filename}" "${serverfiles}"
  49. }
  50. fn_install_server_files_steamcmd(){
  51. counter="0"
  52. while [ "${counter}" == "0" ]||[ "${exitcode}" != "0" ]; do
  53. counter=$((counter+1))
  54. cd "${steamcmddir}"
  55. if [ "${counter}" -le "10" ]; then
  56. # Attempt 1-4: Standard attempt
  57. # Attempt 5-6: Validate attempt
  58. # Attempt 7-8: Validate, delete long name dir
  59. # Attempt 9-10: Validate, delete long name dir, re-download SteamCMD
  60. # Attempt 11: Failure
  61. if [ "${counter}" -ge "2" ]; then
  62. fn_print_warning_nl "SteamCMD did not complete the download, retrying: Attempt ${counter}"
  63. fn_script_log "SteamCMD did not complete the download, retrying: Attempt ${counter}"
  64. fi
  65. if [ "${counter}" -ge "7" ]; then
  66. echo "Removing $(find ${serverfiles} -type d -print0 | grep -Ez '[^/]{30}$')"
  67. find "${serverfiles}" -type d -print0 | grep -Ez '[^/]{30}$' | xargs -0 rm -rf
  68. fi
  69. if [ "${counter}" -ge "9" ]; then
  70. rm -rf "${steamcmddir}"
  71. check_steamcmd.sh
  72. fi
  73. # Detects if unbuffer command is available for 32 bit distributions only.
  74. info_distro.sh
  75. if [ "$(command -v stdbuf 2>/dev/null)" ]&&[ "${arch}" != "x86_64" ]; then
  76. unbuffer="stdbuf -i0 -o0 -e0"
  77. fi
  78. if [ "${counter}" -le "4" ]; then
  79. if [ "${engine}" == "goldsource" ]; then
  80. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" ${branch} +quit
  81. local exitcode=$?
  82. else
  83. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" ${branch} +quit
  84. local exitcode=$?
  85. fi
  86. elif [ "${counter}" -ge "5" ]; then
  87. if [ "${engine}" == "goldsource" ]; then
  88. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" ${branch} validate +quit
  89. local exitcode=$?
  90. else
  91. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" ${branch} validate +quit
  92. local exitcode=$?
  93. fi
  94. fi
  95. elif [ "${counter}" -ge "11" ]; then
  96. fn_print_failure_nl "SteamCMD did not complete the download, too many retrys"
  97. fn_script_log "SteamCMD did not complete the download, too many retrys"
  98. break
  99. fi
  100. done
  101. # Goldsource servers commonly fail to download all the server files required.
  102. # Validating a few of times may reduce the chance of this issue.
  103. if [ "${engine}" == "goldsource" ]; then
  104. 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."
  105. counter="0"
  106. while [ "${counter}" -le "4" ]; do
  107. counter=$((counter+1))
  108. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" ${branch} -validate +quit
  109. local exitcode=$?
  110. done
  111. fi
  112. }
  113. echo ""
  114. echo "Installing ${gamename} Server"
  115. echo "================================="
  116. sleep 0.5
  117. if [ -n "${appid}" ]; then
  118. fn_install_server_files_steamcmd
  119. fi
  120. if [ "${gamename}" == "TeamSpeak 3" ]; then
  121. update_ts3.sh
  122. elif [ "${gamename}" == "Minecraft" ]; then
  123. install_minecraft_eula.sh
  124. update_minecraft.sh
  125. elif [ "${gamename}" == "Mumble" ]; then
  126. update_mumble.sh
  127. elif [ "${gamename}" == "Multi Theft Auto" ]; then
  128. update_mta.sh
  129. elif [ "${gamename}" == "Factorio" ]; then
  130. update_factorio.sh
  131. install_factorio_save.sh
  132. elif [ -z "${appid}" ]||[ "${gamename}" == "GoldenEye: Source" ]||[ "${gamename}" == "Base Defense" ]||[ "${gamename}" == "BrainBread" ]; then
  133. if [ "${gamename}" == "Unreal Tournament" ]; then
  134. install_unreal_tournament_eula.sh
  135. fi
  136. fn_install_server_files
  137. fi
  138. if [ -z "${autoinstall}" ]; then
  139. echo ""
  140. echo "================================="
  141. if ! fn_prompt_yn "Was the install successful?" Y; then
  142. install_retry.sh
  143. fi
  144. fi