check_steamcmd.sh 2.4 KB

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