install_server_files.sh 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #!/bin/bash
  2. # LGSM install_server_files.sh function
  3. # Author: Daniel Gibbs
  4. # Website: http://gameservermanagers.com
  5. lgsm_version="270216"
  6. fn_install_server_files(){
  7. if [ "${gamename}" == "Unreal Tournament 99" ]; then
  8. fileurl="http://gameservermanagers.com/files/UnrealTournament99/ut99-server-451-ultimate-linux.tar.bz2"; filedir="${lgsmdir}/tmp"; filename="ut99-server-451-ultimate-linux.tar.bz2"; run="norun"; force="noforce"; md5="e623fdff5ed600a9bfccab852e18d34d"
  9. elif [ "${gamename}" == "Unreal Tournament 2004" ]; then
  10. fileurl="http://gameservermanagers.com/files/UnrealTournament2004/ut2004-server-3339-ultimate-linux.tar.bz2"; filedir="${lgsmdir}/tmp"; filename="ut2004-server-3339-ultimate-linux.tar.bz2"; run="norun"; force="noforce"; md5="e623fdff5ed600a9bfccab852e18d34d"
  11. fi
  12. fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${run}" "${force}" "${md5}"
  13. fn_dl_extract "${filedir}" "${filename}" "${filesdir}"
  14. }
  15. fn_install_server_files_steamcmd(){
  16. counter="0"
  17. while [ "${counter}" == "0" ]||[ "${exitcode}" != "0" ]; do
  18. counter=$((counter+1))
  19. cd "${rootdir}/steamcmd"
  20. if [ "${counter}" -le "10" ]; then
  21. # Attempt 1-4: Standard attempt
  22. # Attempt 5-6: Validate attempt
  23. # Attempt 7-8: Validate, delete long name dir
  24. # Attempt 9-10: Validate, delete long name dir, re-download SteamCMD
  25. # Attempt 11: Failure
  26. if [ "${counter}" -ge "2" ]; then
  27. fn_printwarningnl "SteamCMD did not complete the download, retrying: Attempt ${counter}:"
  28. fn_scriptlog "SteamCMD did not complete the download, retrying: Attempt ${counter}:"
  29. fi
  30. if [ "${counter}" -ge "7" ]; then
  31. echo "Removing $(find ${filesdir} -type d -print0 | grep -Ez '[^/]{30}$')"
  32. find ${filesdir} -type d -print0 | grep -Ez '[^/]{30}$' | xargs -0 rm -rf
  33. fi
  34. if [ "${counter}" -ge "9" ]; then
  35. rm -rf "${rootdir}/steamcmd"
  36. check_steamcmd.sh
  37. fi
  38. # Detects if unbuffer command is available.
  39. if [ $(command -v unbuffer) ]; then
  40. unbuffer=unbuffer
  41. fi
  42. if [ "${counter}" -le "4" ]; then
  43. if [ "${engine}" == "goldsource" ]; then
  44. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" +quit
  45. local exitcode=$?
  46. else
  47. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit
  48. local exitcode=$?
  49. fi
  50. elif [ "${counter}" -ge "5" ]; then
  51. if [ "${engine}" == "goldsource" ]; then
  52. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" -validate +quit
  53. local exitcode=$?
  54. else
  55. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" -validate +quit
  56. local exitcode=$?
  57. fi
  58. fi
  59. elif [ "${counter}" -ge "11" ]; then
  60. fn_printfailurenl "SteamCMD did not complete the download, too many retrys"
  61. fn_scriptlog "SteamCMD did not complete the download, too many retrys"
  62. break
  63. fi
  64. done
  65. # Goldsource servers commonly fail to download all the server files required.
  66. # Validating a few of times may reduce the chance of this issue.
  67. if [ "${engine}" == "goldsource" ]; then
  68. counter="0"
  69. while [ "${counter}" -le "4" ]; do
  70. counter=$((counter+1))
  71. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" -validate +quit
  72. local exitcode=$?
  73. done
  74. fi
  75. }
  76. echo ""
  77. echo "Installing ${gamename} Server"
  78. echo "================================="
  79. sleep 1
  80. if [ -n "${appid}" ]; then
  81. fn_install_server_files_steamcmd
  82. fi
  83. if [ -z "${appid}" ]||[ "${gamename}" == "GoldenEye: Source" ]; then
  84. fn_install_server_files
  85. fi
  86. if [ -z "${autoinstall}" ]; then
  87. echo ""
  88. echo "================================="
  89. while true; do
  90. read -e -i "y" -p "Was the install successful? [Y/n]" yn
  91. case $yn in
  92. [Yy]* ) break;;
  93. [Nn]* ) install_retry.sh;;
  94. * ) echo "Please answer yes or no.";;
  95. esac
  96. done
  97. fi