check_steamcmd.sh 2.4 KB

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