check_steamcmd.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. fn_fetch_file "http://media.steampowered.com/client/steamcmd_linux.tar.gz" "${steamcmddir}" "steamcmd_linux.tar.gz"
  13. tar --verbose -zxf "${steamcmddir}/steamcmd_linux.tar.gz" -C "${steamcmddir}"
  14. rm -v "${steamcmddir}/steamcmd_linux.tar.gz"
  15. chmod +x "${steamcmddir}/steamcmd.sh"
  16. }
  17. fn_check_steamcmd_user(){
  18. # Checks steamuser is setup.
  19. if [ "${steamuser}" == "username" ]; then
  20. fn_printfailnl "Steam login not set. Update steamuser."
  21. echo " * Change steamuser=\"username\" to a valid steam login."
  22. if [ -d "${scriptlogdir}" ]; then
  23. fn_scriptlog "edit ${selfname}. change steamuser=\"username\" to a valid steam login."
  24. exit 1
  25. fi
  26. fi
  27. # Anonymous user is set if steamuser is missing
  28. if [ -z "${steamuser}" ]; then
  29. fn_printwarnnl "Steam login not set. Using anonymous login."
  30. if [ -d "${scriptlogdir}" ]; then
  31. fn_scriptlog "Steam login not set. Using anonymous login."
  32. fi
  33. steamuser="anonymous"
  34. steampass=""
  35. sleep 2
  36. fi
  37. }
  38. fn_check_steamcmd_sh(){
  39. # Checks if SteamCMD exists when starting or updating a server.
  40. # Re-installs if missing.
  41. steamcmddir="${rootdir}/steamcmd"
  42. if [ ! -f "${steamcmddir}/steamcmd.sh" ]; then
  43. fn_printwarnnl "SteamCMD is missing"
  44. fn_scriptlog "SteamCMD is missing"
  45. sleep 1
  46. fn_install_steamcmd
  47. fi
  48. }
  49. fn_check_steamcmd_guard(){
  50. if [ "${function_selfname}" == "command_update.sh" ]||[ "${function_selfname}" == "command_validate.sh" ]; then
  51. # Checks that steamcmd is working correctly and will prompt Steam Guard if required.
  52. "${steamcmddir}"/steamcmd.sh +login "${steamuser}" "${steampass}" +quit
  53. if [ $? -ne 0 ]; then
  54. fn_printfailurenl "Error running SteamCMD"
  55. fi
  56. fi
  57. }
  58. if [ "${gamename}" == "Unreal Tournament 99" ]||[ "${gamename}" == "Unreal Tournament 2004" ]||[ "${gamename}" == "Mumble" ]||[ "${gamename}" == "Teamspeak 3" ]; then
  59. : # These servers do not require SteamCMD. Check is skipped.
  60. else
  61. fn_check_steamcmd_user
  62. fn_check_steamcmd_sh
  63. fn_check_steamcmd_guard
  64. fi