check_steamcmd.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/bin/bash
  2. # LGSM check_steamcmd.sh function
  3. # Author: Daniel Gibbs
  4. # Website: http://gameservermanagers.com
  5. lgsm_version="160316"
  6. # Description: Checks SteamCMD is installed and correct.
  7. fn_install_steamcmd(){
  8. echo "Installing steamCMD"
  9. if [ ! -d "${steamcmddir}" ]; then
  10. mkdir -v "${steamcmddir}"
  11. fi
  12. curl=$(curl --fail -o "${steamcmddir}/steamcmd_linux.tar.gz" "http://media.steampowered.com/client/steamcmd_linux.tar.gz" 2>&1)
  13. exitcode=$?
  14. echo -e "downloading steamcmd_linux.tar.gz...\c"
  15. if [ $exitcode -eq 0 ]; then
  16. fn_printokeol
  17. else
  18. fn_printfaileol
  19. echo "${curl}"
  20. echo -e "${githuburl}\n"
  21. exit $exitcode
  22. fi
  23. tar --verbose -zxf "${steamcmddir}/steamcmd_linux.tar.gz" -C "${steamcmddir}"
  24. rm -v "${steamcmddir}/steamcmd_linux.tar.gz"
  25. chmod +x "${steamcmddir}/steamcmd.sh"
  26. echo ""
  27. }
  28. fn_check_steamcmd_user(){
  29. # Checks steamuser is setup.
  30. if [ "${steamuser}" == "username" ]; then
  31. fn_printfailnl "Steam login not set. Update steamuser."
  32. echo " * Change steamuser=\"username\" to a valid steam login."
  33. if [ -d "${scriptlogdir}" ]; then
  34. fn_scriptlog "edit ${selfname}. change steamuser=\"username\" to a valid steam login."
  35. exit 1
  36. fi
  37. fi
  38. # Anonymous user is set if steamuser is missing
  39. if [ -z "${steamuser}" ]; then
  40. fn_printwarnnl "Steam login not set. Using anonymous login."
  41. if [ -d "${scriptlogdir}" ]; then
  42. fn_scriptlog "Steam login not set. Using anonymous login."
  43. fi
  44. steamuser="anonymous"
  45. steampass=""
  46. sleep 2
  47. fi
  48. }
  49. fn_check_steamcmd_sh(){
  50. # Checks if SteamCMD exists when starting or updating a server.
  51. # Installs if missing.
  52. steamcmddir="${rootdir}/steamcmd"
  53. if [ ! -f "${steamcmddir}/steamcmd.sh" ]; then
  54. if [ "${function_selfname}" == "command_install.sh" ]; then
  55. fn_install_steamcmd
  56. else
  57. fn_printwarnnl "SteamCMD is missing"
  58. fn_scriptlog "SteamCMD is missing"
  59. sleep 1
  60. fn_install_steamcmd
  61. fi
  62. elif [ "${function_selfname}" == "command_install.sh" ]; then
  63. fn_printinfomation "SteamCMD is already installed..."
  64. fn_printokeol
  65. fi
  66. }
  67. fn_check_steamcmd_guard(){
  68. if [ "${function_selfname}" == "command_update.sh" ]||[ "${function_selfname}" == "command_validate.sh" ]; then
  69. # Checks that steamcmd is working correctly and will prompt Steam Guard if required.
  70. "${steamcmddir}"/steamcmd.sh +login "${steamuser}" "${steampass}" +quit
  71. if [ $? -ne 0 ]; then
  72. fn_printfailurenl "Error running SteamCMD"
  73. fi
  74. fi
  75. }
  76. if [ "${gamename}" == "Unreal Tournament 99" ]||[ "${gamename}" == "Unreal Tournament 2004" ]||[ "${gamename}" == "Mumble" ]||[ "${gamename}" == "Teamspeak 3" ]; then
  77. : # These servers do not require SteamCMD. Check is skipped.
  78. else
  79. fn_check_steamcmd_user
  80. fn_check_steamcmd_sh
  81. fn_check_steamcmd_guard
  82. fi