install_server_files.sh 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. fi
  29. if [ "${counter}" -ge "7" ]; then
  30. echo "Removing $(find ${filesdir} -type d -print0 | grep -Ez '[^/]{30}$')"
  31. find ${filesdir} -type d -print0 | grep -Ez '[^/]{30}$' | xargs -0 rm -rf
  32. fi
  33. if [ "${counter}" -ge "9" ]; then
  34. rm -rf "${rootdir}/steamcmd"
  35. check_steamcmd.sh
  36. fi
  37. # Detects if unbuffer command is available.
  38. if [ $(command -v unbuffer) ]; then
  39. unbuffer=unbuffer
  40. fi
  41. if [ "${counter}" -le "4" ]; then
  42. if [ "${engine}" == "goldsource" ]; then
  43. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" +quit
  44. local exitcode=$?
  45. else
  46. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit
  47. local exitcode=$?
  48. fi
  49. elif [ "${counter}" -ge "5" ]; then
  50. if [ "${engine}" == "goldsource" ]; then
  51. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" -validate +quit
  52. local exitcode=$?
  53. else
  54. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" -validate +quit
  55. local exitcode=$?
  56. fi
  57. fi
  58. elif [ "${counter}" -ge "11" ]; then
  59. fn_printfailurenl "SteamCMD did not complete the download, too many retrys"
  60. break
  61. fi
  62. done
  63. # Goldsource servers commonly fail to download all the server files required.
  64. # Validating a few of times may reduce the chance of this issue.
  65. if [ "${engine}" == "goldsource" ]; then
  66. counter="0"
  67. while [ "${counter}" -le "4" ]; do
  68. counter=$((counter+1))
  69. ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" -validate +quit
  70. local exitcode=$?
  71. done
  72. fi
  73. }
  74. echo ""
  75. echo "Installing ${gamename} Server"
  76. echo "================================="
  77. sleep 1
  78. if [ -n "${appid}" ]; then
  79. fn_install_server_files_steamcmd
  80. fi
  81. if [ -z "${appid}" ]||[ "${gamename}" == "GoldenEye: Source" ]; then
  82. fn_install_server_files
  83. fi
  84. if [ -z "${autoinstall}" ]; then
  85. echo ""
  86. echo "================================="
  87. while true; do
  88. read -e -i "y" -p "Was the install successful? [Y/n]" yn
  89. case $yn in
  90. [Yy]* ) break;;
  91. [Nn]* ) install_retry.sh;;
  92. * ) echo "Please answer yes or no.";;
  93. esac
  94. done
  95. fi