install_server_files.sh 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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 modulename="INSTALL"
  7. local commandaction="Install"
  8. local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  9. fn_install_server_files(){
  10. if [ "${shortname}" == "ahl" ]; then
  11. remote_fileurl="http://linuxgsm.download/ActionHalfLife/action_halflife-1.0.tar.bz2"; local_filedir="${tmpdir}"; local_filename="action_halflife-1.0.tar.bz2"; chmodx="nochmodx" run="norun"; force="noforce"; md5="31430e670692b2eeaa0d1217db4dcb73"
  12. elif [ "${shortname}" == "bf1942" ]; then
  13. remote_fileurl="http://linuxgsm.download/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"
  14. elif [ "${shortname}" == "bb" ]; then
  15. remote_fileurl="http://linuxgsm.download/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"
  16. elif [ "${shortname}" == "cod" ]; then
  17. remote_fileurl="http://linuxgsm.download/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"
  18. elif [ "${shortname}" == "coduo" ]; then
  19. remote_fileurl="http://linuxgsm.download/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"
  20. elif [ "${shortname}" == "cod2" ]; then
  21. remote_fileurl="http://linuxgsm.download/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"
  22. elif [ "${shortname}" == "cod4" ]; then
  23. remote_fileurl="http://linuxgsm.download/CallOfDuty4/cod4x18_1772_dedrun.tar.bz2"; local_filedir="${tmpdir}"; local_filename="cod4x18_1772_dedrun.tar.bz2"; chmodx="nochmodx" run="norun"; force="noforce"; md5="de29f29d79f9cc24574b838daa501e46"
  24. elif [ "${shortname}" == "codwaw" ]; then
  25. remote_fileurl="http://linuxgsm.download/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"
  26. elif [ "${shortname}" == "etl" ]; then
  27. remote_fileurl="http://linuxgsm.download/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"
  28. elif [ "${shortname}" == "ges" ]; then
  29. remote_fileurl="http://linuxgsm.download/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"
  30. elif [ "${shortname}" == "mohaa" ]; then
  31. remote_fileurl="http://linuxgsm.download/MedalofHonorAlliedAssault/moh_revival_v1.12_RC3.5.1.tar.bz2"; local_filedir="${tmpdir}"; local_filename="moh_revival_v1.12_RC3.5.1.tar.bz2"; chmodx="nochmodx" run="norun"; force="noforce"; md5="9d5924486a0cf5e46dd063216aad05c1"
  32. elif [ "${shortname}" == "ns" ]; then
  33. remote_fileurl="http://linuxgsm.download/NaturalSelection/ns_dedicated_server_v32.tar.bz2"; local_filedir="${tmpdir}"; local_filename="ns_dedicated_server_v32.tar.bz2"; chmodx="nochmodx" run="norun"; force="noforce"; md5="499cf63324b76925ada6baf5f2eacd67"
  34. elif [ "${shortname}" == "q2" ]; then
  35. remote_fileurl="http://linuxgsm.download/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"
  36. elif [ "${shortname}" == "q3" ]; then
  37. remote_fileurl="http://linuxgsm.download/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"
  38. elif [ "${shortname}" == "qw" ]; then
  39. remote_fileurl="http://linuxgsm.download/QuakeWorld/nquake.server.linux.190506.full.tar.bz2"; local_filedir="${tmpdir}"; local_filename="nquake.server.linux.190506.full.tar.bz2"; chmodx="nochmodx" run="norun"; force="noforce"; md5="74405ec030463c5e1175e776ab572d32"
  40. elif [ "${shortname}" == "rtcw" ]; then
  41. remote_fileurl="http://linuxgsm.download/ReturnToCastleWolfenstein/iortcw-1.51c-x86_64-server-linux-20190507.tar.bz2"; local_filedir="${tmpdir}"; local_filename="iortcw-1.51c-x86_64-server-linux-20190507.tar.bz2"; chmodx="nochmodx" run="norun"; force="noforce"; md5="6a3be9700372b228d1187422464e4212"
  42. elif [ "${shortname}" == "sfc" ]; then
  43. remote_fileurl="http://linuxgsm.download/SourceFortsClassic/SFClassic-1.0-RC7-fix.tar.bz2"; local_filedir="${tmpdir}"; local_filename="SFClassic-1.0-RC7-fix.tar.bz2"; chmodx="nochmodx" run="norun"; force="noforce"; md5="e0d4cfd298a8a356053f92b1fa7d1002"
  44. elif [ "${shortname}" == "sof2" ]; then
  45. remote_fileurl="http://linuxgsm.download/SoldierOfFortune2/sof2gold-1.03.tar.bz2"; local_filedir="${tmpdir}"; local_filename="sof2gold-1.03.tar.bz2"; chmodx="nochmodx" run="norun"; force="noforce"; md5="871b1dc0dafeeace65b198119e8fa200"
  46. elif [ "${shortname}" == "ts" ]; then
  47. remote_fileurl="http://linuxgsm.download/TheSpecialists/ts-3-linux-final.tar.bz2"; local_filedir="${tmpdir}"; local_filename="ts-3-linux-final.tar.bz2"; chmodx="nochmodx" run="norun"; force="noforce"; md5="38e8a8325339f85a7745117802f940b7"
  48. elif [ "${shortname}" == "ut2k4" ]; then
  49. remote_fileurl="http://linuxgsm.download/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"
  50. elif [ "${shortname}" == "ut99" ]; then
  51. remote_fileurl="http://linuxgsm.download/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"
  52. elif [ "${shortname}" == "ut" ]; then
  53. remote_fileurl="http://linuxgsm.download/UnrealTournament/UnrealTournament-Server-XAN-3525360-Linux.zip"; local_filedir="${tmpdir}"; local_filename="UnrealTournament-Server-XAN-3525360-Linux.zip"; chmodx="noexecute" run="norun"; force="noforce"; md5="cad730ad6793ba6261f9a341ad7396eb"
  54. elif [ "${shortname}" == "ut3" ]; then
  55. remote_fileurl="http://linuxgsm.download/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"
  56. elif [ "${shortname}" == "vs" ]; then
  57. remote_fileurl="http://linuxgsm.download/VampireSlayer/vs_l-6.0_full.tar.bz2"; local_filedir="${tmpdir}"; local_filename="vs_l-6.0_full.tar.bz2"; chmodx="nochmodx" run="norun"; force="noforce"; md5="38a79e44b98578bbdc5b15818493a066"
  58. elif [ "${shortname}" == "wet" ]; then
  59. remote_fileurl="http://linuxgsm.download/WolfensteinEnemyTerritory/enemy-territory.260b.tar.bz2"; local_filedir="${tmpdir}"; local_filename="enemy-territory.260b.tar.bz2"; chmodx="nochmodx" run="norun"; force="noforce"; md5="f833f514bfcdd46b42c111f83350c5a7"
  60. elif [ "${shortname}" == "samp" ]; then
  61. remote_fileurl="https://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"
  62. elif [ "${shortname}" == "zmr" ]; then
  63. remote_fileurl="http://linuxgsm.download/ZombieMasterReborn/zombie_master_reborn_b5_2.tar.bz2"; local_filedir="${tmpdir}"; local_filename="zombie_master_reborn_b5_2.tar.bz2"; chmodx="nochmodx" run="norun"; force="noforce"; md5="d52ef2db376f5d21e3a4ceca85ec8761"
  64. fi
  65. fn_fetch_file "${remote_fileurl}" "${local_filedir}" "${local_filename}" "${chmodx}" "${run}" "${forcedl}" "${md5}"
  66. fn_dl_extract "${local_filedir}" "${local_filename}" "${serverfiles}"
  67. }
  68. fn_install_server_files_steamcmd(){
  69. counter="0"
  70. while [ "${counter}" == "0" ]||[ "${exitcode}" != "0" ]; do
  71. counter=$((counter+1))
  72. if [ -d "${steamcmddir}" ]; then
  73. cd "${steamcmddir}" || exit
  74. fi
  75. if [ "${counter}" -le "10" ]; then
  76. # Attempt 1-4: Standard attempt.
  77. # Attempt 5-6: Validate attempt.
  78. # Attempt 7-8: Validate, delete long name dir.
  79. # Attempt 9-10: Validate, delete long name dir, re-download SteamCMD.
  80. # Attempt 11: Failure.
  81. if [ "${counter}" -ge "2" ]; then
  82. fn_print_warning_nl "SteamCMD did not complete the download, retrying: Attempt ${counter}"
  83. fn_script_log "SteamCMD did not complete the download, retrying: Attempt ${counter}"
  84. fi
  85. if [ "${counter}" -ge "7" ]; then
  86. echo -e "Removing $(find "${serverfiles}" -type d -print0 | grep -Ez '[^/]{30}$')"
  87. find "${serverfiles}" -type d -print0 | grep -Ez '[^/]{30}$' | xargs -0 rm -rf
  88. fi
  89. if [ "${counter}" -ge "9" ]; then
  90. rm -rf "${steamcmddir:?}"
  91. check_steamcmd.sh
  92. fi
  93. # Detects if unbuffer command is available for 32 bit distributions only.
  94. info_distro.sh
  95. if [ "$(command -v stdbuf 2>/dev/null)" ]&&[ "${arch}" != "x86_64" ]; then
  96. unbuffer="stdbuf -i0 -o0 -e0"
  97. fi
  98. if [ "${counter}" -le "4" ]; then
  99. # If GoldSrc (appid 90) servers. GoldSrc (appid 90) require extra commands.
  100. if [ "${appid}" == "90" ]; then
  101. # If using a specific branch.
  102. if [ -n "${branch}" ]; then
  103. ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" -beta "${branch}" +quit
  104. else
  105. ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" +quit
  106. fi
  107. elif [ "${shortname}" == "ac" ]; then
  108. ${unbuffer} ${steamcmdcommand} +@sSteamCmdForcePlatformType windows +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" +quit
  109. # All other servers.
  110. else
  111. if [ -n "${branch}" ]; then
  112. ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update -beta "${branch}" +quit
  113. else
  114. ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" +quit
  115. fi
  116. fi
  117. local exitcode=$?
  118. elif [ "${counter}" -ge "5" ]; then
  119. # If GoldSrc (appid 90) servers. GoldSrc (appid 90) require extra commands.
  120. if [ "${appid}" == "90" ]; then
  121. # If using a specific branch.
  122. if [ -n "${branch}" ]; then
  123. ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" -beta "${branch}" validate +quit
  124. else
  125. ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" validate +quit
  126. fi
  127. local exitcode=$?
  128. elif [ "${shortname}" == "ac" ]; then
  129. ${unbuffer} ${steamcmdcommand} +@sSteamCmdForcePlatformType windows +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" +quit
  130. local exitcode=$?
  131. # All other servers.
  132. else
  133. if [ -n "${branch}" ]; then
  134. ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" -beta "${branch}" validate +quit
  135. else
  136. ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" validate +quit
  137. fi
  138. local exitcode=$?
  139. fi
  140. fi
  141. elif [ "${counter}" -ge "11" ]; then
  142. fn_print_failure_nl "SteamCMD did not complete the download, too many retrys"
  143. fn_script_log "SteamCMD did not complete the download, too many retrys"
  144. break
  145. fi
  146. done
  147. # GoldSrc (appid 90) servers commonly fail to download all the server files required.
  148. # Validating a few of times may reduce the chance of this issue.
  149. if [ "${appid}" == "90" ]; then
  150. fn_print_information_nl "GoldSrc servers commonly fail to download all the server files required. Validating a few of times may reduce the chance of this issue."
  151. counter="0"
  152. while [ "${counter}" -le "4" ]; do
  153. counter=$((counter+1))
  154. if [ -n "${branch}" ]; then
  155. ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" "${branch}" validate +quit
  156. else
  157. ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" validate +quit
  158. fi
  159. local exitcode=$?
  160. done
  161. fi
  162. }
  163. echo -e ""
  164. echo -e "${lightyellow}Installing ${gamename} Server${default}"
  165. echo -e "================================="
  166. fn_sleep_time
  167. if [ "${appid}" ]; then
  168. fn_install_server_files_steamcmd
  169. fi
  170. if [ "${shortname}" == "ts3" ]; then
  171. update_ts3.sh
  172. elif [ "${shortname}" == "mc" ]; then
  173. install_eula.sh
  174. update_minecraft.sh
  175. elif [ "${shortname}" == "mcb" ]; then
  176. update_minecraft_bedrock.sh
  177. elif [ "${shortname}" == "mumble" ]; then
  178. update_mumble.sh
  179. elif [ "${shortname}" == "mta" ]; then
  180. update_mta.sh
  181. elif [ "${shortname}" == "fctr" ]; then
  182. update_factorio.sh
  183. install_factorio_save.sh
  184. elif [ -z "${appid}" ]||[ "${shortname}" == "ahl" ]||[ "${shortname}" == "bd" ]||[ "${shortname}" == "bb" ]||[ "${shortname}" == "ges" ]||[ "${shortname}" == "ns" ]||[ "${shortname}" == "sfc" ]||[ "${shortname}" == "sol" ]||[ "${shortname}" == "ts" ]||[ "${shortname}" == "vs" ]||[ "${shortname}" == "zmr" ]; then
  185. if [ "${shortname}" == "ut" ]; then
  186. install_eula.sh
  187. fi
  188. fn_install_server_files
  189. fi
  190. if [ -z "${autoinstall}" ]; then
  191. echo -e ""
  192. echo -e "================================="
  193. if ! fn_prompt_yn "Was the install successful?" Y; then
  194. install_retry.sh
  195. fi
  196. fi