install_server_files.sh 14 KB

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