check_steamcmd.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/bash
  2. # LGSM check_steamcmd.sh function
  3. # Author: Daniel Gibbs
  4. # Website: http://gameservermanagers.com
  5. lgsm_version="281215"
  6. # Description: Downloads SteamCMD on install and checks if missing before running functions that require SteamCMD
  7. if [ "${gamename}" == "Unreal Tournament 99" ]||[ "${gamename}" == "Unreal Tournament 2004" ]||[ "${gamename}" == "Mumble" ]; then
  8. : # These servers do not require SteamCMD. Check is skipped.
  9. else
  10. # Checks steamuser is setup.
  11. if [ "${steamuser}" == "username" ]; then
  12. fn_printfailnl "Steam login not set. Update steamuser."
  13. echo " * Change steamuser=\"username\" to a valid steam login."
  14. if [ -d ${scriptlogdir} ]; then
  15. fn_scriptlog "edit ${selfname}. change steamuser=\"username\" to a valid steam login."
  16. exit 1
  17. fi
  18. fi
  19. if [ -z "${steamuser}" ]; then
  20. fn_printwarnnl "Steam login not set. Using anonymous login."
  21. if [ -d "${scriptlogdir}" ]; then
  22. fn_scriptlog "Steam login not set. Using anonymous login."
  23. fi
  24. steamuser="anonymous"
  25. steampass=""
  26. sleep 2
  27. fi
  28. # Checks if SteamCMD exists when starting or updating a server.
  29. # Re-installs if missing.
  30. steamcmddir="${rootdir}/steamcmd"
  31. if [ ! -f "${steamcmddir}/steamcmd.sh" ]; then
  32. fn_printwarnnl "SteamCMD is missing"
  33. fn_scriptlog "SteamCMD is missing"
  34. sleep 1
  35. if [ ! -d "${steamcmddir}" ]; then
  36. mkdir -v "${steamcmddir}"
  37. fi
  38. curl=$(curl --fail -o "${steamcmddir}/steamcmd_linux.tar.gz" "http://media.steampowered.com/client/steamcmd_linux.tar.gz" 2>&1)
  39. exitcode=$?
  40. echo -e "downloading steamcmd_linux.tar.gz...\c"
  41. if [ $exitcode -eq 0 ]; then
  42. fn_printokeol
  43. else
  44. fn_printfaileol
  45. echo "${curl}"
  46. echo -e "${githuburl}\n"
  47. exit $exitcode
  48. fi
  49. tar --verbose -zxf "${steamcmddir}/steamcmd_linux.tar.gz" -C "${steamcmddir}"
  50. rm -v "${steamcmddir}/steamcmd_linux.tar.gz"
  51. chmod +x "${steamcmddir}/steamcmd.sh"
  52. fi
  53. if [ "${modulename}" == "Update" ]||[ "${modulename}" == "Validate" ]; then
  54. # Checks that steamcmd is working correctly and will prompt Steam Guard if required.
  55. "${steamcmddir}"/steamcmd.sh +login "${steamuser}" "${steampass}" +quit
  56. if [ $? -ne 0 ]; then
  57. fn_printfailurenl "Error running SteamCMD"
  58. fi
  59. fi
  60. fi